使用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 ED25519 key sent by the remote host is
SHA256:wcCzCiRUmBeVlbU64yUL//kgsOV76tK8w0YlQHU7tiU.
Please contact your system administrator.
Add correct host key in /Users/XXXXXX/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/XXXXXX/.ssh/known_hosts:2
Host key for xsoft.cc has changed and you have requested strict checking.
Host key verification failed.
出现这个问题的原因是,之前通过SSH登陆过远程主机,例如通过域名登录主机,并保存了密钥。现在密钥发生了改变,例如是域名指向的主机发生了变化。这样远程认证发生了变化,与本地记录的密钥就不匹配了。
要解决这个问题,只需要根据提示,在「/Users/XXXXXX/.ssh/known_hosts」文件中添加正确的密钥,或者直接删除远程主机对应的密钥,更加暴力的做法是直接把文件清空(如果有其他的远程主机的密钥,可能要小心一些)。
清空know_host文件:
:> /Users/XXXXXX/.ssh/known_hosts