gitsshssh-keys

Possible DNS spoofing detected. Remote host identification has changed


I recently changed server and as a consequence, I have a new IP address. When I try to use git fetch [remote repository], I get this:

> 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>

I simply need to obtain a new SSH key from the new server and put it in my local computer to fix this, correct? Thank you.


Solution

  • If you actually have a new server and you refer to it with the same name or the same IP of the old one, then it's more than likely that the ssh keys are not the same and you would get a spoofing warning message for it. in the message you can see that ssh is pointing to the line where the old key information is: /c/Users/[username]/.ssh/known_hosts:1. Long story short: If you changed server then it's expected that ssh keys are not the same. Just remove the line from the ssh known_hosts for the old server (1st line of your file in this case) and you'll be fine.