Mac OS X Remove SSH Known Host

Posted on in Categories , last updated December 15, 2009

I‘ve reinstalled Linux on remote server and now trying to connect it over ssh using Mac OS X:
ssh user@server1.example.com

But I’m getting an error which read as follows:

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

How do I fix this problem under Mac OX X?

You need to run the following command to get rid of this problem. Open the terminal and type the following command:

ssh-keygen -R server-name
ssh-keygen -R server.ip.addre.ss
ssh-keygen -R 202.54.1.5
ssh-keygen -R server1.example.com
Fig.01: Removing /Users/user/.ssh/known_hosts file
Fig.01: Removing /Users/user/.ssh/known_hosts file

Now you can connect to remote host with ssh:

ssh user@server1.example.com

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

12 comment

  1. I was having the same problem as I was setting up a lots of routers with the same IP over ssh. What worked for me was to remove known_hosts file which is stored in ~/.ssh/knonw_host. So what I did was updating my /etc/bashrc file with the following lines:

    rmknownhosts()
    {
    rm ~/.ssh/known_hosts
    }

    Than when this message appeared I simply typed rmknownhosts and delete the file.

    I don`t know if this is right step to deal with that. But it definitely worked for me.

    Hope that helps.

Leave a Comment