How to fix the git warning "ECDSA host key for 'github.com' differs from the key for the IP address '140.82.113.3'"

Jared Nielsen - Apr 8 '23 - - Dev Community

If GitHub's recent RSA SSH host key update causes your system to throw this error:

Warning: the ECDSA host key for 'github.com' differs from the key for the IP address '140.82.113.3'
Enter fullscreen mode Exit fullscreen mode

The solution is a quick fix. The next lines of the error will read something like this:

Offending key for IP in ~/.ssh/known_hosts:X
Matching host key in ~/.ssh/known_hosts:Y
Are you sure you want to continue connecting (yes/no)?
Enter fullscreen mode Exit fullscreen mode

Where X is the line number containing the IP address we want to remove. So...

Run the following command:

vi ~/.ssh/known_hosts
Enter fullscreen mode Exit fullscreen mode

And ⬇️ to line X and run the following to delete the line and exit vi:

dd
:x
Enter fullscreen mode Exit fullscreen mode

Voila!

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .