ServerFault 和 StackOverflow 上有很多关于“无法确定主机真实性”的问题。例如:
https://stackoverflow.com/questions/2360842/ec2-ssh-problem-authenticating
和这个:
https://stackoverflow.com/questions/11443687/the-authenticity-of-host-cant-be-established
在这些问题的评论中,有些人抱怨这个问题没有解决方案。这个问题对我来说是慢慢积累起来的,但现在我无法绕过它。
我在 8 月 9 日创建了一个新的 EC2 实例,并创建了一个新的密钥对。我下载了密钥,并使用它通过 ssh 连接到服务器。我将此别名添加到我的.bash_profile
文件中:
别名 lynssh='ssh -vvv -i /Users/jgallant/projects/sugarbest/susan-ecommerce-demo.pem [电子邮件保护] ‘
这最初是有效的。我输入了“lynssh”,然后我看到:
The authenticity of host 'ec2-22-90-226.compute-1.amazonaws.com (52.20.110.126)' can't be established.
ECDSA key fingerprint is SHA256:Ogme1H3edswKHrnfBLCO9bwNd+X//dHbka8mtoc.
Are you sure you want to continue connecting (yes/no)? yes
我输入“是”并登录。我工作了 4 个小时,然后停下来吃午饭。当我吃完午饭回来时,我的 Macbook 关机时自动注销了,所以我再次登录。
我又被问到:
The authenticity of host 'ec2-22-90-226.compute-1.amazonaws.com (52.20.110.126)' can't be established.
ECDSA key fingerprint is SHA256:Ogme1H3edswKHrnfBLCO9bwNd+X//dHbka8mtoc.
Are you sure you want to continue connecting (yes/no)? yes
然后我再次输入“是”,然后我就进去工作了几个小时。
第二天当我开始工作时我又被问到:
The authenticity of host 'ec2-22-90-226.compute-1.amazonaws.com (52.20.110.126)' can't be established.
ECDSA key fingerprint is SHA256:Ogme1H3edswKHrnfBLCO9bwNd+X//dHbka8mtoc.
Are you sure you want to continue connecting (yes/no)? yes
我再次输入“是”,然后又完成了几个小时的工作。
但是现在我无法再进入。我输入“lynssh”并得到:
The authenticity of host 'ec2-22-90-226.compute-1.amazonaws.com (52.20.110.126)' can't be established.
ECDSA key fingerprint is SHA256:Ogme1H3edswKHrnfBLCO9bwNd+X//dHbka8mtoc.
Are you sure you want to continue connecting (yes/no)? yes
我输入“是”,然后我看到的是:
Failed to add the host to the list of known hosts (/Users/jgallant/.ssh/known_hosts).
[email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
我检查了 AWS 上的 EC2 控制台,以确保服务器运行正常。结果确实如此。它没有重新启动,IP 仍然相同。EC2 实例运行的是标准 Amazon Linux,没有任何修改。
所以我首先出现了一个症状:每次登录时都会被问到“您确定要继续吗”。
现在我遇到了一个真正的问题:我根本无法登录。
我删掉了:
~/.ssh/known_hosts
然后我lynssh
又试了一次。
已成功写入有关此主机的信息,~/.ssh/known_hosts
因此问题已解决。但我仍然无法访问服务器。
当我ssh
使用该vvv
选项运行时,我得到:
OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /Users/jgallant/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to ec2-22-90-226.compute-1.amazonaws.com port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jgallant/projects/sugarbest/susan-ecommerce-demo.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jgallant/projects/sugarbest/susan-ecommerce-demo.pem-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
debug3: fd 5 is O_NONBLOCK
debug1: Authenticating to ec2-22-90-226.compute-1.amazonaws.com:22 as 'ec2-user'
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: [email protected],[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected],zlib
debug2: compression stoc: none,[email protected],zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,cast128-cbc,3des-cbc
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,cast128-cbc,3des-cbc
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected]
debug2: compression stoc: none,[email protected]
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:Ogme1H3edswKHrnfBLCO9bwNd+X//dHbka8mtoc
The authenticity of host 'ec2-22-90-226.compute-1.amazonaws.com (52.20.110.126)' can't be established.
ECDSA key fingerprint is SHA256:Ogme1H3edswKHrnfBLCO9bwNd+X//dHbka8mtoc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ec2-22-90-226.compute-1.amazonaws.com,52.20.110.126' (ECDSA) to the list of known hosts.
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 134217728 blocks
debug2: key: /Users/jgallant/projects/sugarbest/susan-ecommerce-demo.pem (0x0), explicit
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
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: /Users/jgallant/projects/sugarbest/susan-ecommerce-demo.pem
debug3: sign_and_send_pubkey: RSA SHA256:cq/vY8nn8pqDjuS6VUHYYrINfcaG0Jct0ITBtLOLk28
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).