SSH公開鍵ログイン:2つの異なる鍵とSSH_AUTH_SOCKの動作

SSH公開鍵ログイン:2つの異なる鍵とSSH_AUTH_SOCKの動作

user1Ubuntu 12.04デスクトップのユーザー()には、~/.ssh/id_rsa~/.ssh/id_rsa1および.pubファイル)という2つのSSH RSAキーが設定されています。どちらの公開鍵もuser1@myserverサーバーアカウント()の認証鍵に設定されています。

デスクトップ(クライアント)コンピュータにログインし、Gnome Terminalを使用すると、2つのキーのいずれかを使用してサーバーにログインできます。

  • ssh user1@myserver暗黙的に拾った/home/user1/.ssh/id_rsa
  • ssh -f /home/user1/.ssh/id_rsa1 user1@myserverまた動作します。

localhostGnomeデスクトップを介してログインせずに他のホスト(またはさらに)からSSHを介してクライアントシステムにログインしても、使用は機能しなくなりsuます/home/user1/.ssh/id_rsa

SSH_AUTH_SOCKこれは、(元のSSHを使用してクライアント設定に接続した環境で欠落している)に関連しているようです。デスクトップセッションに表示される値に設定すると、/tmp/keyring-xxxxxxxxxxx/sshログインはid_rsa再び正常に機能します。

設定を解除してSSH_AUTH_SOCK(ロギングをid_rsa再度失敗させて)(およびファイル)id_rsa1にコピーしても機能します。id_rsa.pubid_rsa

これら2つのキーペア間の動作の違いとの相互作用の違いは何で説明できますかSSH_AUTH_SOCK

サーバーログには何も表示されません。

以下は、違いが発生する直前のSSHクライアントログの断片です。

debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/user1/.ssh/id_rsa (0x7f6b7059b260)
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/user1/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply

次に、そのユーザー/キーに対して機能しない場合:

debug1: Authentications that can continue: publickey,password
debug2: we did not send a packet, disable method

ベストアンサー1

結局、機能しないキーはauthorized_keysファイルに正しく設定されていないことがわかりました。すみません...

私はこれがssh -i /home/user1/.ssh/id_rsa user1@myserver正しく設定されていることを示すと誤って考えましたが、そうではありません。他のキーも使用します。ssh -i /home/user1/.ssh/id_rsa -oIdentitiesOnly=yes user1@myserver誤った構成によって適用が失敗する可能性があります。

私はGnomeとしてログインするときに設定されたSSHエージェントを使用すると、ディレクトリ~/.ssh/の他のキーも取得するので-i

おすすめ記事