Skip to content

解决Host key verification failed

一、发现问题

问题如下代码:

shell
ssh root@xx.xx.xx.xx
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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:DC7IuwdOlXkDRhNgEEqKxTr189VNyW0/an2tg2ErSU8.
Please contact your system administrator.
Add correct host key in /Users/yangjinfu/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/yangjinfu/.ssh/known_hosts:20
Host key for xx.xx.xx.xx has changed and you have requested strict checking.
Host key verification failed.

这里面,有一句很关键。

ECDSA host key for 108.61.163.242 has changed and you have requested strict checking.
Host key verification failed.

一般这个问题,是你重置过你的服务器后。你再次想访问会出现这个问题。

二、解决问题

解决问题也很简单:

shell
$ ssh-keygen -R 你要访问的IP地址

例如:

shell
$ ssh-keygen -R 108.61.163.242

贴个图更直观

在这里插入图片描述

好啦。很简单的一个小问题。 搞技术,还是得一点一滴的慢慢积累。不积硅步无以至千里。

前端知识体系 · wcrane