在 Ubuntu 终端采用 SSH 连接服务器时, ssh ubuntu@xxx.xxx.xxx.xxx, 出现类似于下面的错误:

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
e3:67:c8:86:49:5e:f1:65:68:30:33:28:6d:bb:8b:2e.
Please contact your system administrator.
Add correct host key in /home/hgf/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/aihgf/.ssh/known_hosts:8
  remove with: ssh-keygen -f "/home/hgf/.ssh/known_hosts" -R xxx.xxx.xxx.xxx
ECDSA host key for xxx.xxx.xxx.xxx has changed and you have requested strict checking.
Host key verification failed.

解决方案:

  • 方案 1:
sudo rm -rf ~/.ssh/known_hosts # 删除已有known_hosts 文件
  • 方案 2:
ssh-keygen -R xxx.xxx.xxx.xxx(服务器ip)
Last modification:October 9th, 2018 at 09:31 am