“提供RSA公钥:”在ssh期间找不到正确的密钥到我的AWS实例

时间:2017-04-21 07:32:50

标签: amazon-web-services ssh pem

当我正在抨击时,我对这个对讲的含义感到困惑。

我觉得如果我能理解它,我可以解决我遇到的问题,也就是说,我得到了 debug1: No more authentication methods to try. Permission denied (publickey).

这是对讲:

OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to ec2-xx-xx-x-xx.us-west-2.compute.amazonaws.com [xx.xx.x.xx] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /me/key_B.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file /me/key_Bt type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.1
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.1 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to ec2-xx-xx-x-xx.us-west-2.compute.amazonaws.com:22 as 'ec2-user'
debug3: hostkeys_foreach: reading file "/me/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /me/.ssh/known_hosts:9
debug3: load_hostkeys: loaded 1 keys from ec2-xx-xx-x-xx.us-west-2.compute.amazonaws.com
debug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-nistp256,ecdsa-nistp384,ecdsa-nistp521
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: curve25519-56@libssh.org,ecdh-nistp256,ecdh-nistp384,ecdh-nistp521,diffie-hellman-group-exchange-56,diffie-hellman-group-exchange-1,diffie-hellman-group14-sha1,diffie-hellman-group1-
debug2: kex_parse_kexinit: ecdsa--nistp256-cert-v01@openssh.com,ecdsa-nistp384-cert-v01@openssh.com,ecdsa-nistp521-cert-v01@openssh.com,ecdsa-nistp256,ecdsa-sha2-nistp384,ecdsa-nistp521,ssh-ed25-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-dss-cert-v00@openssh.com,ssh-ed,ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,arc256,arc128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arc,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: chacha20-poly1305@openssh.com,aes-ctr,aes192-ctr,aes256-ctr,aes-gcm@openssh.com,aes256-gcm@openssh.com,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-md5-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-md5-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,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: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1
debug2: kex_parse_kexinit: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
debug2: kex_parse_kexinit: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: kex_parse_kexinit: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: kex_parse_kexinit: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: kex_parse_kexinit: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
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 
debug1: kex: server->client chacha20-poly1305@openssh.com <implicit> none
debug1: kex: client->server chacha20-poly1305@openssh.com <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:OWvg35+ziszO+1muZwu+vwk8awGkedK4/N7iAy4l93A
debug3: hostkeys_foreach: reading file "me/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /me/.ssh/known_hosts:9
debug3: load_hostkeys: loaded 1 keys from ec2-xx-xx-x-xx.us-east-2.compute.amazonaws.com
debug3: hostkeys_foreach: reading file "/me/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /me/.ssh/known_hosts:9
debug3: load_hostkeys: loaded 1 keys from 52.43.3.81
debug1: Host 'ec2-xx-xx-x-xx.us-west-2.compute.amazonaws.com' is known and matches the ECDSA host key.
debug1: Found key in /me/.ssh/known_hosts:9
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: me/.ssh/mobrien_mac_20161019 (0x7f9da3f00080),
debug2: key: /Users/matthewobrien/Dropbox/key_B (0x0), explicit
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
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: Offering RSA public key: /me/.ssh/key_A**
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
**debug1: Trying private key: /me/key_B**
debug3: sign_and_send_pubkey: RSA SHA256:WAZzLsdfdsfasdfaspTYXXXXXXiS4wzvTasdfasdfTB/q0B0
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).

第一个粗体显示ssh正在尝试提供私钥key_A。但key_A是一个不同的密钥,与完全不同的服务器相关。它与我试图访问的AWS实例无关。

第二个粗体线是找到正确的密钥key_B。但等等,这是私钥?这是我在AWS控制台上生成并在登录时尝试使用的密钥。

为什么ssh首先尝试访问随机公钥,然后开始寻找私钥?它找不到正确的公钥。

我的ssh是:

ssh -i /me/somedir/key_B.pem ec2-user@XXXXX.us-east-2.compute.amazonaws.com

为什么ssh不会出现在正确的位置?

提前致谢。

1 个答案:

答案 0 :(得分:0)

  

为什么ssh首先尝试访问随机公钥,

因为它很可能配置为。您在~/.ssh/config/etc/ssh/ssh_config中拥有什么?

  

然后开始寻找私钥?它找不到正确的公钥。

     

我的ssh是:

ssh -i /me/somedir/key_B.pem  ec2-user@XXXXX.us-east-2.compute.amazonaws.com
     

为什么ssh不会出现在正确的位置?

debug1: identity file /me/key_B.pem type -1

因为它不懂钥匙。它要么格式错误,要么以某种方式破坏。它看起来怎么样?