错误信息
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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:9ilzwuITbEYMSgrGhmNzeKVfJYaw+8EKE3p+emG5kG4.
Please contact your system administrator.
Add correct host key in /Users/guohang/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/guohang/.ssh/known_hosts:5
Host key for xxx.xxx.xxx.xxx has changed and you have requested strict checking.
Host key verification failed.
背景
刚开始使用华为云的时候,由于选择的是Cent OS的系统镜像,后续在学习docker以及k8s时出现了错误,因此将系统镜像重装为ubuntu。由于重新装机,导致无法通过SSH远程登录服务器。
本地主机:系统MacOs Monterey,型号:MacBook Air(M1,2020)
解决办法
在查询资料之后,选择使用了如下的办法
第一步:本地主机打开终端,通过如下命令进入.ssh
cd ~/.ssh
有解决方案采取修改 ssh目录下 的 known_hosts 文件中所有的机器IP和域名的方式,单该方式会影响其他的远程系统,本文采取下面的方式
第二步:使用ssh-keygen -R的命令对要进行远程连接的ip为 xxx.xxx.xxx.xxx的服务器的信息进行更新
ssh-keygen -R 121.xxx.xxx.243
显示如下的结果表示已经成功
# Host 121.xxx.xxx.243 found: line 1
# Host 121.xxx.xxx.243 found: line 2
# Host 121.xxx.xxx.243 found: line 3
/Users/xxxxx/.ssh/known_hosts updated.
Original contents retained as /Users/xxxxx/.ssh/known_hosts.old