检测到可能的 DNS 欺骗。远程主机标识已更改

Possible DNS spoofing detected. Remote host identification has changed

我最近更换了服务器,因此有了一个新的 IP 地址。当我尝试使用 git fetch [remote repository] 时,我得到这个:

C:\Users[path]\app>git fetch [remote repository] @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @
WARNING: POSSIBLE DNS SPOOFING DETECTED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ The RSA host key for example.net has changed, and the key for the corresponding IP address [IP address of new server] is unknown. This could either mean that DNS SPOOFING is happening or the IP address for the host and its host key have changed at the same time. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @
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 RSA key sent by the remote host is SHA256:ep0A2t+sVMSaIEbS8wt8ptfmdHSr1kNocWsBNab0tsI. Please contact your system administrator. Add correct host key in /c/Users/[username]/.ssh/known_hosts to get rid of this message. Offending RSA key in /c/Users/[username]/.ssh/known_hosts:1 RSA host key for example.net has changed and you have requested strict checking. Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. C:\Users[path]\app>

我只需要从新服务器获取一个新的 SSH 密钥并将其放入我的本地计算机即可解决此问题,对吗?谢谢。

如果您实际上有一个新服务器并且您使用与旧服务器相同的名称或相同的 IP 引用它,那么 ssh 证书很可能不相同,您会收到欺骗警告消息。在消息中,您可以看到 ssh 指向旧证书信息所在的行:/c/Users/[用户名]/.ssh/known_hosts:1。长话短说:如果您更改了服务器,那么预计 ssh 证书会有所不同。只需从旧服务器的 ssh known_hosts 中删除该行(在本例中为文件的第一行)就可以了。

警告信息在这里给出了更好的解释。 example.net 的 RSA 主机密钥已更改,相应 IP 地址 [新服务器的 IP 地址] 的密钥未知。

让我们比较一下更改 example.net (10.0.0.0) 的 IP 之前和更改 example.net (10.0.0.1) 的 IP 之后的两种情况。

更改前:example.net - 10.0.0.0

10.0.0.2>> ssh 用户@example.net 服务器 10.0.0.0 的主机指纹存储在服务器 10.0.0.2 的已知主机文件中。

更改后:example.net - 10.0.0.1

10.0.0.2>> ssh 用户@example.net 现在 example.net 指向 10.0.0.1 但在已知主机文件中 example.net 仍然具有 10.0.0.0 的主机指纹。因此,每当您尝试 ssh 到 example.net 时都会收到警告,因为主机密钥已更改,因为它是新服务器。根据 ssh,它认为其他人可以访问您的 DNS,并且可能将 DNS 的端点更改为任何错误的服务器,这就是您面临 DNS 欺骗警告的原因。

要确认它,您需要对 ssh 说出您是故意更改它的人。为此,只需从服务器 10.0.0.2 的 known_host 文件中删除旧的主机密钥条目并删除 10.0.0.0.

的条目

找到服务器的指纹:

ssh-keygen -F example.net

删除服务器的指纹:

ssh-keygen -R example.net