Fix the 'host key verification failed' issue
Unproofread notes
If getting "host key verification failed" error when ssh
ing to a server this is the issue:
This happens when the IP got a different SSH host key than what your Mac saved earlier – common if you rebuilt the server or your provider reused the IP. SSH blocks the login to protect you from a man-in-the-middle.
Something like the below:
ssh root@1.2.3.4
# output
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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 ED255 key sent by the remote host is
SHA256:EsWKr/gOT/GHcFMYIUvhgaTss6+.
Please contact your system administrator.
Add correct host key in /Users/deepak/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/deepak/.ssh/known_hosts:9
Host key for 1.2.3.4 has changed and you have requested strict checking.
Host key verification failed.
And the fix is to update just that host’s key instead of deleting the whole file.
ssh-keygen -R 1.2.3.4
# If you also connect by a hostname, remove that too:
ssh-keygen -R your-hostname.example.com
And then connect again to the server, and it should work.
- ← Previous
No em dashes anymore
Comment via email