パスフレーズが設定されていない公開鍵でSSHがパスフレーズを要求する

パスフレーズが設定されていない公開鍵でSSHがパスフレーズを要求する

私はしばらくの間、サーバー上で公開鍵認証を使用してきましたが、新しい「クライアント」が接続しようとすると問題が発生します。ギットハブ権限が正しく設定されていることを確認するために多くのスレッドを読み、github 用の新しいキーを生成しました。私が直面している問題は、パスフレーズを設定していないにもかかわらず、ssh がパスフレーズを要求していることです。パスフレーズを入力していないことを 100% 確実にするために、キーを再作成しました。

ssh -vvv次のような関連出力が得られます。

debug1: Offering public key: /home/me/.ssh/github.pub
debug2: we sent a publickey packet, wait for reply
debug3: Wrote 368 bytes for a total of 1495
debug1: Remote: Forced command: gerve mygithubusername c3:71:db:34:98:30:6d:c2:ca:d9:51:a8:c6:1b:fc:f7
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug2: input_userauth_pk_ok: fp c3:71:db:34:98:30:6d:c2:ca:d9:51:a8:c6:1b:fc:f7
debug3: sign_and_send_pubkey
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Enter passphrase for key '/home/me/.ssh/github.pub': 

なぜそれが私に言っているのか理解しようとしたPEM_read_秘密キー失敗しましたが、解決策が見つかりません。

エージェントなどは使用していません。~/.ssh/config ファイルを次のように構成します。

Host github
Host github.com
Hostname github.com
User git
PubkeyAuthentication yes
IdentityFile /home/me/.ssh/github.pub

前もって感謝します。

答え1

IdentityFileオプションを使用すると、~/.ssh/configプライベートをポイントします。一般人ではない、 鍵。

からman ssh_config

アイデンティティファイル
ユーザーの DSA、ECDSA、または DSA 認証 ID を読み取るファイルを指定します。プロトコル バージョン 1 のデフォルトは ~/.ssh/identity、プロトコル バージョン 2 のデフォルトは ~/.ssh/id_dsa、~/.ssh/id_ecdsa、および ~/.ssh/id_rsa です。

したがって、~/.ssh/configエントリは次のようになります。

Host github.com
Hostname github.com
User git
PubkeyAuthentication yes
IdentityFile /home/me/.ssh/github

答え2

この問題が発生しましたが、これはカット アンド ペースト エラーでした。%キー ファイルの末尾に 1 つの記号が追加されていました (つまり、最後の行は でした-----END RSA PRIVATE KEY-----%)。キーの長さが間違っている、または形式が間違っていることを示すエラーやデバッグ情報などはありませんでしたが、ssh はパスフレーズを要求しました。

答え3

私の場合、問題は SSH クライアントが ED25519 キーをサポートしていないことでした。解決策は、代わりに RSA キーを作成して使用することです。

この問題は、OpenSSH < 6.5(実行ssh -V)およびパテ < 0.68

これは次の出力で確認できますssh -vvv

debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,[email protected]
debug2: kex_parse_kexinit: hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96
debug2: kex_parse_kexinit: hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: kex_parse_kexinit: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ssh-ed25519
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: none,[email protected]

最初のブロックはクライアントがサポートするものを記述し、2番目のブロックはサーバーがサポートするものを記述します。ご覧のとおり、上半分には「curve25519」についての言及がなく、クライアントがそれをサポートしていないことを示しています。

答え4

私のチームでは、この問題が発生した場合、ローカルの問題ではありません。ユーザーの SSH キーやアクセスが、接続先のサーバー (この場合はホスティング プラットフォーム) で正しく構成されていません。何らかの理由で、存在しない SSH キーを求めるプロンプトが表示されます。

関連情報