通过 ssh 连接远程主机的时候,经常会碰到如下错误,这通常是由于服务器IP\用户名等信息变更导致的

[root@localhost ~]# ssh 192.168.1.x
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 the RSA 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 /root/.ssh/known_hosts to get rid of this message.
Offending key in /root/.ssh/known_hosts:33
RSA host key for 192.168.1.x has changed and you have requested strict checking.
Host key verification failed.

有两种解决办法

  1. 直接删除下面的文件,或者删除know_hosts中的对应192.168.1.x的连接

~/.ssh/known_hosts
  1. 使用 ssh-keygen

ssh-keygen -R 192.168.1.x