ssh登录出现Host key verification failed.解决办法

今天通过ssh链接Ubuntu服务器

192:~ mysite$ ssh [email protected]

出现如下错误提示信息:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 ECDSA key sent by the remote host is
SHA256:Nrw48y2B4eQuc2LNhL0edaFnOcX4.
Please contact your system administrator.
Add correct host key in /Users/mysite/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/mysite/.ssh/known_hosts:1
ECDSA host key for xxx.xx.xx.xxx has changed and you have requested strict checking.
Host key verification failed.

错误提示中出现关键词:

Add correct host key in /Users/mysite/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/mysite/.ssh/known_hosts:1

原因是在主机子系统每次成功ssh连接远程操作,都会把你每个你访问过计算机的公钥(public key)都记录在主机的目录/Users/icarus/.ssh/known_hosts下,当下次访问相同子机服务器时,会核对公钥。如果公钥不同,会发出警告,避免你受到DNS Hijack之类的攻击。

解决办法:

进入目录删除文件即可,然后重新连接就能发现连接上了。

192:~ mysite$ cd ~/.ssh/
192:.ssh mysite$ rm known_hosts

重新使用ssh链接服务器即可使用。

参考链接:参考链接

你可能感兴趣的:(ssh登录出现Host key verification failed.解决办法)