今天,我尝试通过 SSH 连接到我的远程 Ubuntu 20.04 LTS 服务器并遇到此消息 – 警告:远程主机标识已更改!.
$ 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:K/jEKNQCYYOilJxOZc7qAWlu4xu0nW+MD09DfJL7+gc. Please contact your system administrator. Add correct host key in /home/sk/.ssh/known_hosts to get rid of this message. Offending ECDSA key in /home/sk/.ssh/known_hosts:11 remove with: ssh-keygen -f "/home/sk/.ssh/known_hosts" -R "192.168.225.52" ECDSA host key for 192.168.225.52 has changed and you have requested strict checking. Host key verification failed.
这实际上不是错误消息。 这只是一个安全通知,表明自上次连接以来给定远程系统的 ECDSA 主机密钥已更改。 您可能已经知道,当我们第一次通过 SSH 从本地系统访问远程系统时,该远程主机发送的 ECDSA 密钥的指纹被缓存并存储在 $HOME/.ssh/known_hosts
我们本地系统中的文件。
当您重新安装远程系统或为多个远程系统分配相同的 IP 地址后身份(指纹)发生更改时,将显示上述警告消息。
修复 Linux 中的“警告:远程主机标识已更改”错误
要解决此问题,只需使用以下命令删除本地系统上 IP 地址的缓存密钥:
$ ssh-keygen -R 192.168.225.52
示例输出:
# Host 192.168.225.52 found: line 11 /home/sk/.ssh/known_hosts updated. Original contents retained as /home/sk/.ssh/known_hosts.old