报错Host key verification failed.

应用环境:对新安装替换的linux系统(IP使用了以前的IP),使用ssh命令远程时报错

报错信息:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 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 7e:28:94:20:1f:f8:a8:3e:99:01:93:b9:b1:9b:7b:2d. 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:1 RSA host key for 172.16.253.197 has changed and you have requested strict checking. Host key verification failed.

原因:

~/.ssh/known_hosts 文件生成的有之前系统的远程key信息

~/.ssh/known_hosts 为 /root/.ssh/known_hosts

生成信息如下:

172.16.253.197 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCXUYzMIl0QzxmPtOgbbq1OniCGKXG+XhagsW/mfcsxWlswfdCIdIKKTsKvylb3nCofr11CRF4TfijYs069fGSIyQ/Oxbv9i2ZqMDSwXmliK8nJB2mrdeq58jSygA+PiXt9C6gp2sMmKjFYCFTngPZ0TK8FadUWbXhh0oT7N/3dxiTWIUTxlqbADK3f9D1bvQprrIsvtbtTRDW6pDSPBlJjc9IoeXUYxOKRsYeaFSPeTKMpa/ZHbCJo1lHFKkzGXBLQvvWB/j15xJO22kYhB8nEuVHNX8q25FWDVV/ao0Ysy7JA+YdDuipCjDC5iGACA4COdB+IbW8ydEdu7jlyJfop

处理办法:

清除目的主机对应信息(如清除上文生成信息)

vim ~/.ssh/known_hosts

再次尝试:

[root@localhost .ssh]# ssh root@172.16.253.197 The authenticity of host '172.16.253.197 (172.16.253.197)' can't be established. RSA key fingerprint is 7e:28:94:20:1f:f8:a8:3e:99:01:93:b9:b1:9b:7b:2d. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '172.16.253.197' (RSA) to the list of known hosts. root@172.16.253.197's password:

输入密码连接成功

如果对您有所帮助请《点赞》、《收藏》、《转发》,您的支持是我持续更新的动力,有疑问请留言