当自己在ssh 登陆另一台服务器的时候,出现以下错误:
[root@lgc ~]# ssh root@172.16.0.118
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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 ECDSA key sent by the remote host is
SHA256:TBdOjhzVPapIMjsMWKZq5RYYwb3TSjzJ2PeGgFLaUws.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /root/.ssh/known_hosts:1
ECDSA host key for 172.16.0.118 has changed and you have requested strict checking.
Host key verification failed.
说明:
此错误说明是此服务器中的公钥钥匙,连接不了对方的服务器,可能是对方服务器的公钥发生改变,所以,需要在本地更新公钥;
有如下解决方案:
1、可以直接ssh-keygen -R ip
直接更新对接公钥;
例如,我需要连接的ip是172.16.0.118,则:
[root@lgc ~]# ssh-keygen -R 172.16.0.118 ssh-keygen -R 172.16.0.118
2、进入known_hosts 此文件中,删除关于对方IP的公钥;
例如,我需要连接的服务器为172.16.0.118,那么只需要删除关于这台服务器的公钥即可,如下:
[root@lgc .ssh]# vi known_hosts
[root@lgc .ssh]# vi known_hosts
192.168.6.55 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAylzdHAyNTYAAABBBF00Sc6O50yEnc+DNL2W3/kkt+1sgagdB6ORvTHOn/dB0rHumibGct0VniCwR7sxmTh+rWvJVmUio=
172.16.0.118 ecdsa-sha2-nistp256 AAAAE2VjItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBAu2VujlpwoQRsCy5BjXQd47pm1s2qdBMtxolLYluXYH42GO+6YnUIc7vkFIEygJhEbIoOi3U/k+s=
删除以上172.16.0.118的一行信息即可;