
私は Hadoop を学習しており、本に定義されている手順に従ってパスワードなしの SSH を作成しようとしています。Hadoop: 決定版ガイド
SSHの設定
疑似分散モードは、(単一の)ホストが localhost である完全分散モードの特殊なケースにすぎないため、localhost に SSH 接続してパスワードを入力せずにログインできることを確認する必要があります。
まず、SSHがインストールされていることを確認してください サーバーが稼働している(これについてはよく分かりませんが、何を意味するのでしょうか)。たとえば、Ubuntu では、次のようにして実現できます。
sudo apt-get install ssh
次に、パスワードなしのログインを有効にするには、空のパスフレーズを持つ新しい SSH キーを生成します。
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
実行する必要があるかもしれませんssh 追加ssh-agent を実行している場合は、次のコマンドで接続できることをテストします。
ssh localhost
成功した場合、パスワードを入力する必要はありません。
すべて正常に動作しているようですが、パスワードの入力を求められます。ルート アクセスにも使用するログイン パスワードを入力していますが、まったく機能しません。アドバイスをお願いします。
情報を追加します。古いキーを削除し、新しいキーを追加しました。
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
この後の私のファイル権限は
-rw-rw-r-- 1 incredible incredible 403 मई 24 17:16 authorized_keys
-rw------- 1 incredible incredible 1679 मई 23 23:08 id_rsa
-rw-r--r-- 1 incredible incredible 403 मई 23 23:08 id_rsa.pub
-rw-r--r-- 1 incredible incredible 444 मई 24 17:12 known_hosts
Authorized_keyの権限を変更した後は
-rw------- 1 incredible incredible 403 मई 24 17:16 authorized_keys
-rw------- 1 incredible incredible 1679 मई 23 23:08 id_rsa
-rw-r--r-- 1 incredible incredible 403 मई 23 23:08 id_rsa.pub
-rw-r--r-- 1 incredible incredible 444 मई 24 17:12 known_hosts
しかし、その後もパスワードの入力を求められますssh localhost
ssh -v localhost
@heemayl からの質問に対する詳細情報出力の追加
incredible@incredible:~$ ssh -v localhost OpenSSH_6.7p1 Ubuntu-5ubuntu1, OpenSSL 1.0.1f 6 Jan 2014 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug1: Connecting to localhost [127.0.0.1] port 22. debug1: Connection established. debug1: identity file /home/incredible/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /home/incredible/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/incredible/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/incredible/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/incredible/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/incredible/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/incredible/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/incredible/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.7p1 Ubuntu-5ubuntu1 debug1: Remote protocol version 2.0, remote software version OpenSSH_6.7p1 Ubuntu-5ubuntu1 debug1: match: OpenSSH_6.7p1 Ubuntu-5ubuntu1 pat OpenSSH* compat 0x04000000 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-ctr [email protected] none debug1: kex: client->server aes128-ctr [email protected] none debug1: sending SSH2_MSG_KEX_ECDH_INIT debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ECDSA 3c:e1:36:10:30:19:b3:e1:43:73:a5:6c:76:9e:24:67 debug1: Host 'localhost' is known and matches the ECDSA host key. debug1: Found key in /home/incredible/.ssh/known_hosts:1 debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: Roaming not allowed by server debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,password,keyboard-interactive debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/incredible/.ssh/id_rsa debug1: Authentications that can continue: publickey,password,keyboard-interactive debug1: Trying private key: /home/incredible/.ssh/id_dsa debug1: Trying private key: /home/incredible/.ssh/id_ecdsa debug1: Trying private key: /home/incredible/.ssh/id_ed25519 debug1: Next authentication method: keyboard-interactive debug1: Authentications that can continue: publickey,password,keyboard-interactive debug1: Next authentication method: password incredible@localhost's password:
@heemayl : 以下は出力ですssh -vvv localhost
debug1: Offering RSA public key: /home/incredible/.ssh/id_rsa debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,password,keyboard-interactive debug1: Offering RSA public key: incredible@incredible debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,password,keyboard-interactive debug1: Trying private key: /home/incredible/.ssh/id_dsa debug3: no such identity: /home/incredible/.ssh/id_dsa: No such file or directory debug1: Trying private key: /home/incredible/.ssh/id_ecdsa debug3: no such identity: /home/incredible/.ssh/id_ecdsa: No such file or directory debug1: Trying private key: /home/incredible/.ssh/id_ed25519 debug3: no such identity: /home/incredible/.ssh/id_ed25519: No such file or directory debug2: we did not send a packet, disable method debug3: authmethod_lookup keyboard-interactive debug3: remaining preferred: password debug3: authmethod_is_enabled keyboard-interactive debug1: Next authentication method: keyboard-interactive debug2: userauth_kbdint debug2: we sent a keyboard-interactive packet, wait for reply debug1: Authentications that can continue: publickey,password,keyboard-interactive debug3: userauth_kbdint: disable: no info_req_seen debug2: we did not send a packet, disable method debug3: authmethod_lookup password debug3: remaining preferred: debug3: authmethod_is_enabled password debug1: Next authentication method: password incredible@localhost's password:
答え1
この問題はファイルの権限が原因です~/.ssh/authorized_keys
。ファイルの権限は、他のユーザーがファイルに書き込めるようなものであってはなりません。
たとえば、権限が 8 進数として設定されている場合666
(これはまさに悪魔的です !!)、他のすべての人がファイルへの書き込み権限を持っているため~/.ssh/authorized_keys
、ファイルは によって無視されssh
、パスワードの入力を求められます。
ファイルが~/.ssh/authorized_keys
事前に存在しないと仮定すると、次のコマンド
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
~/.ssh/authorized_keys
値によって決定された権限でファイルを作成しumask
、ファイルの内容を追加します~/.ssh/id_rsa.pub
。
したがって、解決策としては、ファイルの権限を変更して、自分だけが書き込み可能になるようにします。例:
chmod 600 ~/.ssh/authorized_keys