Ubuntu-ssh - - 警告:远程主机识别已更改

时间:2011-12-28 09:28:55

标签: ssh openssh

我无法ssh和rsync到远程系统。它不断给出此错误消息:

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
a3:8f:7c:07:c9:12:d8:aa:cd:c2:ba:b3:27:68:bc:c2.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending RSA key in /root/.ssh/known_hosts:8
RSA host key for xxx.xxx.xxx.xxx has changed and you have requested strict checking.
Host key verification failed.
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(601) [sender=3.0.8]

我已从authorized_keys删除了/home/user/.ssh个文件。

5 个答案:

答案 0 :(得分:122)

使用以下命令从.ssh / known_hosts文件中删除旧密钥

ssh-keygen -R <host>

答案 1 :(得分:67)

消息显示“/root/.ssh/known_hosts”未授权_keys。 从中删除该文件(或至少相应的密钥),您可以再次访问!但要注意:密钥必须有变化的原因。系统是否重新安装?确保你检查或ssh的整个想法是无效的。

BTW。:你是否有理由以ssh身份出现?

答案 2 :(得分:20)

该消息确实解释了自己:

  • 远程主机使用密钥
  • 标识自己
  • 您之前使用该主机密钥的副本
  • 因此,远程主机可能不是他们所说的

如果您信任远程主机,则可以从/root/.ssh/known_hosts删除第8行,ssh会询问您下次尝试连接时是否可以添加新密钥

如果您不信任远程主机,则必须联系主机管理员以了解他们是否以及为何更改了ssh密钥。如果没有,则意味着您的流量被截获

另一方面,如果您真的非常信任远程主机(例如,它位于Intranet上),则可以使用

运行ssh
-oBatchMode=yes -oStrictHostKeyChecking=no

答案 3 :(得分:12)

您可以使用sed从known_hosts文件中删除第8行的有问题的密钥:

sed -i -e 8d /root/.ssh/known_hosts

答案 4 :(得分:5)

这样做:

mv .ssh/known_hosts .ssh/known_hosts_old