Mac/Linux – SSH Host Key Verification Failed

If you get the following message when you connecting to a server through SSH, most likely the server side has changed authorization key.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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 the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
5c:9b:16:56:a6:cd:11:10:3a:cd:1b:a2:91:cd:e5:1c.
Please contact your system administrator.
Add correct host key in /Users/user/.ssh/known_hosts to get rid of this message.
Offending key in /Users/user/.ssh/known_hosts:1
RSA host key for server1.example.com has changed and you have requested strict checking.
Host key verification failed.

 

In this case, you have to clear the RSA key fingerprint in your client machine by either one of the following commands in terminal.

  • ssh-keygen -R <Server IP address>
  • ssh-keygen -R <Server hostname>

 

Try the SSH connection again, it will prompt asking if you want to add the new RSA key fingerprint. Just take yes and the connection should be established without problem. It should work in both Mac, Ubuntu and maybe other Linux OSs.

Done =)

Reference: Mac OS X Remove SSH Known Host

Advertisements

2 thoughts on “Mac/Linux – SSH Host Key Verification Failed”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.