问题现象: 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 a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:NHg/pDwRdtQThZzY3Z4Uwq/Rz93FgmL3UdBAFleWFWk.
Please contact your system administrator.
Add correct host key in /Users/yuanting/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/yuanting/.ssh/known_hosts:102
ECDSA host key for 192.168.198.190 has changed and you have requested strict checking.
Host key verification failed.
原因:
因为服务器的ip发生变更了 第一次SSH连接时,会生成一个认证,储存在客户端(也就是用SSH连线其他电脑的那个,自己操作的那个)中的known_hosts,但是如果服务器验证过了,认证资讯当然也会更改,服务器端与客户端不同时,就会跳出错误啦。
解决办法:
输入命令:ssh-keygen -R +输入服务器的IP 例如:
~ ssh-keygen -R 192.168.198.147 ✔
# Host 192.168.198.147 found: line 36
/Users/renwoxing/.ssh/known_hosts updated.
或者
rm ~/.ssh/known_hosts