ssh 链接远程服务器出现错误解决办法

2022-08-22

ssh 链接远程服务器出现错误:

❯ ssh ubuntu@117.50.183.62
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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:8QBi5WlPcgZpJxxbiRepWlmKf2YpMEZjEPXo/w.
Please contact your system administrator.
Add correct host key in /Users/lihui/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/lihui/.ssh/known_hosts:11
Host key for 117.50.183.62 has changed and you have requested strict checking.
Host key verification failed.

原因:
第一次ssh链接的时候会生成一个认证凭据,存储在客户端中的known_hosts,如果服务器地址重置or重新安装了,就会产生这个问题,达拉崩吧。。。

解决:

ssh-keygen -R 服务器地址

❯ ssh-keygen -R 117.50.183.62
# Host 117.50.183.62 found: line 9
# Host 117.50.183.62 found: line 10
# Host 117.50.183.62 found: line 11
/Users/lihui/.ssh/known_hosts updated.
Original contents retained as /Users/lihui/.ssh/known_hosts.old

然后重新链接

奈斯。