Jee*_*gre 16 ssh authentication amazon-ec2
我已经设置了一个带有 Rails 包的 Ubuntu 实例,部署了我的应用程序,它运行良好。
但是,当我尝试做SSH,这不是让我对远程登录并抛出这样的错误:Host key verification failed。
问题似乎一直存在。我已将弹性 IP 附加到该实例,但无法看到公共 DNS。
我的实例在新加坡地区运行。
ssh 调试输出:
OpenSSH_5.8p1 Debian-7ubuntu1, OpenSSL 1.0.0e 6 Sep 2011
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 46.137.253.231 [46.137.253.231] port 22.
debug1: Connection established.
debug1: identity file st.pem type -1
debug1: identity file st.pem-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-4ubuntu6
debug1: match: OpenSSH_5.5p1 Debian-4ubuntu6 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.8p1 Debian-7ubuntu1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is.
Please contact your system administrator.
Add correct host key in /home/ubuntu/.ssh/known_hosts to get rid of this message.
Offending RSA key in /home/ubuntu/.ssh/known_hosts:1
remove with: ssh-keygen -f "/home/ubuntu/.ssh/known_hosts" -R 46.137.253.231
RSA host key for 46.137.253.231 has changed and you have requested strict checking.
Host key verification failed.
Run Code Online (Sandbox Code Playgroud)
flu*_*rdy 22
当您连接到 ssh 服务器时,您的 ssh 客户端会将可信主机列表作为 IP 和 ssh 服务器指纹的键值对保存。使用 ec2,您经常会在多个服务器实例中重复使用相同的 IP,这会导致冲突。
如果您使用此 IP 连接到较早的 ec2 实例,现在连接到具有相同 IP 的新实例,您的计算机将抱怨“主机验证失败”,因为其先前存储的对不再与新对匹配。
错误消息告诉您如何修复它:
/home/ubuntu/.ssh/known_hosts:1
中的违规 RSA 密钥删除:ssh-keygen -f "/home/ubuntu/.ssh/known_hosts" -R 46.137.253.231"
或者,只需打开 /home/ubuntu/.ssh/known_hosts 并删除第 1 行(如“:1”所示)。
您现在可以连接并接收新的主机验证。
请注意通常 ssh 的 known_hosts 文件通常为主机名或 ip6 值存储了第二行对,因此您可能需要删除几行。
警告:主机验证很重要,这是您收到此警告的一个很好的原因。确保您预计主机验证会失败。如果不确定,请勿删除验证键值对。
Gre*_*cki 12
@flurdy的答案是一次性解决方案。
但如果你经常:
..无使用弹性IP地址(永久连接到您的服务器),那么你应对新/更改IP地址/您的实例的主机名的所有时间。
如果是这样,那么您可能希望永久停止 SSH 检查和存储 EC2 公共主机名的服务器指纹。
为此,只需将其添加到您的~/.ssh/config:
# AWS EC2 public hostnames (changing IPs)
Host *.compute.amazonaws.com
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
Run Code Online (Sandbox Code Playgroud)
请注意,SSHWarning: Permanently added (...) to the list of known hosts.在连接时仍会提示,但仅表示已将其添加到/dev/null...
但是,SSH 将停止询问您是否confirm the authenticity of host继续连接。
因此它更方便,您可以避免在使用 EC2 实例时并不总是足够详细的 SSH 连接错误。
我必须补充一点,理论上此设置会降低 SSH 连接的安全性,但在现实生活中,您可能无论如何都不会检查一次性 EC2 实例的指纹。
| 归档时间: |
|
| 查看次数: |
25625 次 |
| 最近记录: |