ssh WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! 解决

发布时间 2023-09-04 10:36:23作者: _小孟同学

今天登录堡垒机发现 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:xxxxzU3o.
Please contact your system administrator.
Add correct host key in /home/.ssh/known_hosts to get rid of this message.
Offending RSA key in /home/.ssh/known_hosts:3
Host key for xxx.com has changed and you have requested strict checking.
Host key verification failed.

解决方案:

vim /home/.ssh/known_hosts

删除 xxx.com 变化的那一行,然后重新登录

sudo ssh user@xxx.com

注意,大多数情况下 再次登录需要加 sudo,因为要往.ssh/known_hosts 里写数据