質問: awsec2サーバーの新規ユーザーにputty秘密鍵を使用する awsec2インスタンスを開始しました。 amazonによって生成されたssh秘密鍵を使用して、ユーザーec2-userでインスタンスに接続できます。 http://docs.aws.amazon.com/awsec2/latest/userguide/managing-users.html の指示に従って、新しいユーザー「bob」の認証情報を追加しました。新しいユーザーボブを作成し、putty keygeneratorを使用して新しい公開鍵と秘密鍵のセットを生成しました。公開鍵を/home/bob/.ssh/authorized_keysのec2インスタンスに移動しました/home/bob/.sshと/home/bob/.ssh/authorized_keysの所有者とグループをbob:bobに変更しました/home/bob/.sshのアクセス許可を700に変更しました/home/bob/.ssh/authorized_keysのアクセス許可を600に変更しましたec2インスタンスにbobとしてsshで接続しようとすると、bobの秘密鍵を使用してエラーが発生します。putty fatal error disconnected: no supported authentication methods available (server sent: pulickey,gssapi-keyex,gssapi-with-mic) puttyコンソールには次のように表示されます。using username "bob". server refused our key また、コマンドラインからbobの秘密鍵を使用してec2インスタンスにsshで接続しようとしましたが、一般的ではありませんでした。キーのパスフレーズを受け入れませんでした。パスフレーズのないキーペアも試してみましたが、それでもパスワードの入力を求められ、サーバーにアクセスできませんでした。これが私の非常に冗長な出力です$ ssh -vvv -i bobs_key.ppk bob@ec2-12-345-678-910.us-west-2.compute.amazonaws.com openssh_4.6p1, openssl 0.9.8e 23 feb 2007 debug2: ssh_connect: needpriv 0 debug1: connecting to ec2-12-345-678-910.us-west-2.compute.amazonaws.com [12.345.678.910] port 22. debug1: connection established. debug3: not a rsa1 key file bobs_key.ppk. debug2: key_type_from_name: unknown key type 'putty-user-key-file-2:' debug3: key_read: missing keytype debug2: key_type_from_name: unknown key type 'encryption:' debug3: key_read: missing keytype debug2: key_type_from_name: unknown key type 'comment:' debug3: key_read: missing keytype debug2: key_type_from_name: unknown key type 'public-lines:' debug3: key_read: missing keytype debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug2: key_type_from_name: unknown key type 'private-lines:' debug3: key_read: missing keytype debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug2: key_type_from_name: unknown key type 'private-mac:' debug3: key_read: missing keytype debug1: identity file bobs_key.ppk type -1 debug1: remote protocol version 2.0, remote software version openssh_6.4 debug1: match: openssh_6.4 pat openssh* debug1: enabling compatibility mode for protocol 2.0 debug1: local version string ssh-2.0-openssh_4.6 debug2: fd 3 setting o_nonblock debug1: ssh2_msg_kexinit sent debug1: ssh2_msg_kexinit received 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: ssh-rsa,ssh-dss debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,a es256-ctr debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,a es256-ctr debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib debug2: kex_parse_kexinit: none,zlib@openssh.com,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: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-grou p14-sha1,diffie-hellman-group1-sha1 debug2: kex_parse_kexinit: ssh-rsa,ecdsa-sha2-nistp256 debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,ae s192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,ae s192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se debug2: kex_parse_kexinit: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@ openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,h mac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@ openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,h mac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96 debug2: kex_parse_kexinit: none,zlib@openssh.com debug2: kex_parse_kexinit: none,zlib@openssh.com debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: first_kex_follows 0 debug2: kex_parse_kexinit: reserved 0 debug2: mac_init: found hmac-md5 debug1: kex: server->client aes128-cbc hmac-md5 none debug2: mac_init: found hmac-md5 debug1: kex: client->server aes128-cbc hmac-md5 none debug1: ssh2_msg_kex_dh_gex_request(1024<1024<8192) sent debug1: expecting ssh2_msg_kex_dh_gex_group debug2: dh_gen_key: priv key bits set: 140/256 debug2: bits set: 512/1024 debug1: ssh2_msg_kex_dh_gex_init sent debug1: expecting ssh2_msg_kex_dh_gex_reply debug3: check_host_in_hostfile: filename /c/users/bob/.ssh/known_hosts debug3: check_host_in_hostfile: match line 1 debug3: check_host_in_hostfile: filename /c/users/bob/.ssh/known_hosts debug3: check_host_in_hostfile: match line 1 debug1: host 'ec2-12-345-678-910.us-west-2.compute.amazonaws.com' is known and matches the rsa host key. debug1: found key in /c/users/bob/.ssh/known_hosts:1 debug2: bits set: 501/1024 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: ssh2_msg_service_request sent debug2: service_accept: ssh-userauth debug1: ssh2_msg_service_accept received debug2: key: bobs_key.ppk (0x0) debug1: authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic debug3: preferred 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: trying private key: bobs_key.ppk debug1: pem_read_privatekey failed debug1: read pem private key done: type <unknown> enter passphrase for key 'bobs_key.ppk': debug1: pem_read_privatekey failed debug1: read pem private key done: type <unknown> debug2: bad passphrase given, try again... enter passphrase for key 'bobs_key.ppk': debug1: pem_read_privatekey failed debug1: read pem private key done: type <unknown> debug2: bad passphrase given, try again... enter passphrase for key 'bobs_key.ppk': debug1: pem_read_privatekey failed debug1: read pem private key done: type <unknown> debug2: bad passphrase given, try again... debug2: we did not send a packet, disable method debug1: no more authentication methods to try. permission denied (publickey,gssapi-keyex,gssapi-with-mic). puttyログ:2015-02-08 08:35:15 looking up host "ec2-12-345-678-910.us-west-2.compute.amazonaws.com" 2015-02-08 08:35:15 connecting to 12.345.678.910 port 22 2015-02-08 08:35:15 server version: ssh-2.0-openssh_6.4 2015-02-08 08:35:15 using ssh protocol version 2 2015-02-08 08:35:15 we claim version: ssh-2.0-putty_release_0.62 2015-02-08 08:35:15 doing diffie-hellman group exchange 2015-02-08 08:35:15 doing diffie-hellman key exchange with hash sha-256 2015-02-08 08:35:16 host key fingerprint is: 2015-02-08 08:35:16 ssh-rsa 2048 b6:76:a5:c6:06:dc:3c:d6:c2:65:fe:f5:55:27:b9:ef 2015-02-08 08:35:16 initialised aes-256 sdctr client->server encryption 2015-02-08 08:35:16 initialised hmac-sha1 client->server mac algorithm 2015-02-08 08:35:16 initialised aes-256 sdctr server->client encryption 2015-02-08 08:35:16 initialised hmac-sha1 server->client mac algorithm 2015-02-08 08:35:16 reading private key file "c:\bob.ppk" 2015-02-08 08:35:16 pageant is running. requesting keys. 2015-02-08 08:35:16 pageant has 1 ssh-2 keys 2015-02-08 08:35:16 configured key file not in pageant 2015-02-08 08:35:16 offered public key 2015-02-08 08:35:16 server refused our key 2015-02-08 08:35:16 using sspi from secur32.dll 2015-02-08 08:35:16 attempting gssapi authentication 2015-02-08 08:35:16 gssapi authentication request refused 2015-02-08 08:35:16 disconnected: no supported authentication methods available (server sent: publickey,gssapi-keyex,gssapi-with-mic) サーバーsshdログ:feb 8 08:35:16 ip-101-10-101-1 sshd[3182]: error: received disconnect from 22.33.44.555: 14: no supported authentication methods available [preauth] これはputtyによって生成された公開鍵の例です---- begin ssh2 public key ---- comment: "rsa-key-20150209" aaaab3nzac1yc2eaaaabjqaaaqeas2f7svx8kou0rvzqh0r6uwws/tb5uxo7+qes cxf+0cf3vwleon+cnw1hqhy7edhhgw4eyvl/erbiyv4i8hgge/ife4qpuomy3vtz znjqembsy32lgsx/flqbylw+xzyc4lezv3tszjfyyik8ilrbozdkp4cdyek0rprb pptllqy5l95h1unmuornga93ylqvki/dsnkvkytrjocgbrxr5pept5y9lsehylea drbpogsf9lyj/hdeaoijbhgqu+czrdzzsxgtv3+nepekoev1xc8tyj83jihcrx3p bjoujhlltwa2tl40xm913dkussbha2fbd0wbchry9y2blpua9q== ---- end ssh2 public key ---- これは、それに付随する秘密鍵の例ですputty-user-key-file-2: ssh-rsa encryption: aes256-cbc comment: rsa-key-20150209 public-lines: 6 aaaab3nzac1yc2eaaaabjqaaaqeas2f7svx8kou0rvzqh0r6uwws/tb5uxo7+qes cxf+0cf3vwleon+cnw1hqhy7edhhgw4eyvl/erbiyv4i8hgge/ife4qpuomy3vtz znjqembsy32lgsx/flqbylw+xzyc4lezv3tszjfyyik8ilrbozdkp4cdyek0rprb pptllqy5l95h1unmuornga93ylqvki/dsnkvkytrjocgbrxr5pept5y9lsehylea drbpogsf9lyj/hdeaoijbhgqu+czrdzzsxgtv3+nepekoev1xc8tyj83jihcrx3p bjoujhlltwa2tl40xm913dkussbha2fbd0wbchry9y2blpua9q== private-lines: 14 up7yt8e9awk159t5xo1p0mr5abauhth9hzjfw98igbayhco9atuhoyxvumbuhnub 1+2aiucv22xuujiwdjrddx3usmumsdxpps4li6govdgmbo66bclaqnbwnuzs7ogx ffq23tzspndbroqwncnol9suf7ma6u6s7sacfsflxaucsre9iiyxcrlxafval/ah bd3ltd4i49sicrjmw3veandx6r0qqmq5gjzorqhu1i2b4dydqqvaothysfxtr9p4 nhtvoeo+qi7qtmzzmruaekh7tc+4j8idhn5e3k6hpzv8z0e7arjbtph8gdbg1fl2 zevcjx2s4b4bgl9a9vzxzllg/tikzbr0qavhttu5spgvicsgkeakteisqclkt/vt kl8uopaalyoertso9hnuewuz99ak7wjzvkrghiupioqbsa7c7yj/hlq/ofkozqgj lp6bssa0gky5zncphusircu5xcdo9cnnkaxwf5qjjfw9udqzhrif19jgzo6nlyml sxgba+bxmn+15big1r23me/vtbzokrbmcgvrflz4vlgiytwbtnniafizixvhuvgs pwig2e4ornkz+n1g92ri0mgoyk+wmoajaocbmwsiegfbtqwdaxliegtyu/npuifd rbufwc/kiosm/gvbiuoeycdbr6ksi3ozdhcqkyufsuk67vp2bgfs9jxre98/yhvq wxgxthfwz2p6kqdiurdwutnoo2iyrbbezwxsophujkqaioc6xblfflkm4xxadxl1 vsuagxbnz2bjfbxifwnvslf60sxoeggvxyxx3euvktpbtb6yy6aein7vjdjqmpn5 +jz/paznxubhlzqbvbxyf9mbgacqgmv3b8dtil3bcvfcudv/jytdsftcgysgbs0s private-mac: 44a5eabcdebd7d33a1c99f72016563d26b435832
回答: 公開鍵を質問(authorized_keys)に示されている形式で---- begin ssh2 public key ----ファイルに貼り付けた場合、それは機能しません。"opensshauthorized_keysファイルに貼り付けるための公開鍵"というラベルの付いたputtygenに示されている1行の形式を使用する必要があります。それは次のようになります:rsa-key aaaab3nzac1yc2eaaaabjqaaaqeas2f7svx8kou0rvzqh0r6uwws/tb5uxo7+qescxf+0cf3vwleon+cnw1hqhy7edhhgw4eyvl/erbiyv4i8hgge/ife4qpuomy3vtzznjqembsy32lgsx/flqbylw+xzyc4lezv3tszjfyyik8ilrbozdkp4cdyek0rprbpptllqy5l95h1unmuornga93ylqvki/dsnkvkytrjocgbrxr5pept5y9lsehyleadrbpogsf9lyj/hdeaoijbhgqu+czrdzzsxgtv3+nepekoev1xc8tyj83jihcrx3pbjoujhlltwa2tl40xm913dkussbha2fbd0wbchry9y2blpua9q== rsa-key-20150209