Ubuntu的SSH – – 警告:远程主机标识已更改

我无法ssh和rysnc远程系统。 它不断给这个错误消息:

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] 

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

该消息显示“ /root/.ssh/known_hosts authorized_keys。 从中删除该文件(或至less相应的键),你可以再次去! 但是请注意:钥匙改变必须有一个原因。 系统是否重新安装? 确保你检查或者ssh的全部想法是无效的。

顺便说一句:是否有你的SSH作为根的原因?

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

 ssh-keygen -R <host> 

该消息确实解释了它自己:

  • 远程主机使用密钥标识自己
  • 您之前的主机密钥的副本是不同的
  • 所以有可能远程主机不是他们所说的那个人

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

如果您不信任远程主机,则必须联系主机pipe理员以了解是否以及为什么更改了ssh密钥。 如果他们没有,这意味着你的stream量正在被拦截

另一方面,如果你真的信任远程主机(例如它在一个内部网上),你可以运行ssh

 -oBatchMode=yes -oStrictHostKeyChecking=no 

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

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

只要这样做:

 mv .ssh/known_hosts .ssh/known_hosts_old