【Error】ssh登陆报错:WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

我们使用ssh-keygen登陆服务的时候,如果是第一次登陆,会返回server的信息要求我们确认,如果没问题,输入yes之后就会发送我们的private key用于认证,个人觉得这是为了防止private key泄漏。但是如果该ip对应的服务器变更了(如在vps销毁了服务器又重新申请到一个相同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 a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:Zguo2pYQI44wxwif5W7Y0VyQpvRYiLA4RQUtCV3Sz0s.
Please contact your system administrator.
Add correct host key in /XXXX/XXXX/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /XXXX/XXXX/.ssh/known_hosts:39
ECDSA host key for 149.28.XX.XX has changed and you have requested strict checking.

解决办法:

ssh-keygen -R ip  #从known_hosts中删除对应的entry,这样再ssh时就相当于是一台新的服务器了。

-R hostname Removes all keys belonging to hostname from a known_hosts file. This option is useful to delete hashed hosts (see the -H option above).

【Error】ssh登陆报错:WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!_第1张图片参考

https://stackoverflow.com/questions/20840012/ssh-remote-host-identification-has-changed

你可能感兴趣的:(遇到的错误)