SSHクライアントはssh-agentで私のキーを試みません。

SSHクライアントはssh-agentで私のキーを試みません。

私はOS X Yosemite 10.10.5を使用していますが、SSHクライアントが私が説明したり変更したりできないように動作しています。

私の目標は、以下を介してサーバーに接続することです。

ssh -A [email protected]

これを追加すると、SSHクライアントが自分のキー以外のキーを-v試すことができないことがわかります。~/.ssh/id_rsassh-agentが実行中であることを確認し、目的のssh-add -lキーが追加されたことを確認するために使用しました。

これは私のローカルbashプロンプトで実行されます。

# Run ssh-agent
bash-3.2$ eval $(ssh-agent)
Agent pid 7786

# Confirm it's running
bash-3.2$ sudo ps aux | grep ssh-agent
josh             7794   0.0  0.0  2432772    676 s000  S+    1:32PM   0:00.00 grep ssh-agent
josh             7786   0.0  0.0  2480640   2180   ??  Us    1:31PM   0:00.04 ssh-agent

# Login successfully by explicitly specifying a key
bash-3.2$ ssh -i sandbox [email protected]
Last login: Tue Aug 18 20:13:31 2015 from X.Y.189.46
CoreOS stable (723.3.0)
core@ip-10-200-4-138 ~ $ exit
logout
Connection to 12.34.56.78 closed.

# Now attempt to connect using ssh-agent
bash-3.2$ ssh-add sandbox
Identity added: sandbox (sandbox)
bash-3.2$ ssh -A [email protected]

# My just-added key isn't tried, so I'm prompted for a password
[email protected]'s password:

どんな助けでも大変感謝します!

修正する: 要求に応じて詳細な出力は次のとおりです。

bash-3.2$ ssh -v -A [email protected]
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /Users/josh/.ssh/config
debug1: /Users/josh/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: /etc/ssh_config line 102: Applying options for *
debug1: Connecting to 12.34.56.78 [12.34.56.78] port 22.
debug1: Connection established.
debug1: identity file /Users/josh/.ssh/id_rsa type 1
debug1: identity file /Users/josh/.ssh/id_rsa-cert type -1
debug1: identity file /Users/josh/.ssh/id_dsa type -1
debug1: identity file /Users/josh/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.7
debug1: match: OpenSSH_6.7 pat OpenSSH*
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: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<2048<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA a8:d9:fb:07:a6:71:de:99:76:9e:55:9c:bd:68:87:55
debug1: Host '12.34.56.78' is known and matches the RSA host key.
debug1: Found key in /Users/josh/.ssh/known_hosts:164
debug1: ssh_rsa_verify: signature correct
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: /Users/josh/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /Users/josh/.ssh/id_dsa
debug1: Next authentication method: keyboard-interactive
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: password

ベストアンサー1

述べたように、このsshコマンドにはというキーが必要ですid_rsa

これを行うとき:

$ ssh-add sandbox

sandboxエージェントというキーを追加します。

したがって、違いがあります。

SSHコマンドラインの解決策は、ファイル識別オプションを使用することです。

ssh -i ~/.ssh/other_keys/sandbox ...

メモ: 厳しい制限があるため、他のキーにはサブフォルダを使用します。ただし、各キーを持つ多くのサーバーにアクセスすると問題が発生する可能性があります。https://askubuntu.com/questions/419546/ssh-never-ask-for-a-passwordもっと学ぶ。

-iこのオプションを常に使用したくない場合は、次の情報を~/.ssh/configファイルに追加してください。

Host example.com
  Hostname example.com
  User YourUserName
  PasswordAuthentication no
  HostbasedAuthentication no
  IdentitiesOnly yes
  IdentityFile /home/<your-user-name>/.ssh/other_keys/sandbox

sshこれでオプションが独自に見つかります。IdentifyFile検索はに基づいていますHost。たとえば、次のように、実際にその行のすべての名前を使用できます。

Host remote-sandbox
  ...

使用できるように

$ ssh remote-sandbox

コマンドラインremote-sandboxでは/etc/hosts

ssh-addこのコマンドをまったく使用する必要はありません。コマンドを初めて実行すると、パスワードの入力をssh求められ、使用可能なプロキシがあれば自動的にパスワードが保存されます。未使用のコンピュータでコマンドを実行する必要がある場合(またはDockerなどのシステムを使用してキーをプリロードすると入力シェルが終了するため)、使用するとssh-add便利です。sshdocker build ...

おすすめ記事