SSH RSA host key has just been changed


 Introducton

When a domain has been moved from one server to another or a machine has been formatted, issue with SSH login occurs. The warning dialog that most SSH programs give looks something like this:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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
06:ea:f1:f8:db:75:5c:0c:af:15:d7:99:2d:ef:08:2a.
Please contact your system administrator.
Add correct host key in /home/user/.ssh/known_hosts to get rid of this message.
Offending key in /home/user/.ssh/known_hosts:4
RSA host key for domain.com has changed and you have requested strict checking.
Host key verification failed.
The SSH program will print this message and often exit, prohibiting the user from connecting to the remote machine.
This problem arises when a site has changed servers, and the new server RSA key which is transmitted when authenticating is different from the old server
or
when a linux box is formatted it creates a new set of RSA keys for ssh authentication. Since old RSA key is stored in your known_host file when you last ssh to the remote machine, ssh will not let you login to that machine till you save the correct new RSA key. You can do it in 2 ways:

Solution

In the case of a migration, you can be reasonably sure that the RSA key change is not an accident, but to connect to the new server you must remove the line in .ssh/known_hosts that corresponds to your domain name. This can be done by editing ‘known_hosts’ by hand or if your machine has Perl installed you can use this one liner:
perl -p -i -e 's/^example.com.*n//;' ~/.ssh/known_hosts
Substitute your actual domain for example.com making sure to include a backslash before the dot. If you have several domains that have moved you must repeat this step for each one.
or
You can simply delete the RSA key which is stored against the IP of remote machine to which you are doing SSH from your /yourhome/.ssh/known_hosts file.
Afer this restart the SSH service and you are done.
# service sshd restart

About Alex Hunt

Hi All I am Manish Kumar Jha aka Alex Hunt. I am currently working in VMware Software India Pvt Ltd as Operations System Engineer (vCloud Air Operations). I have around 5 Years of IT experience and have exposure on VMware vSphere, vCloud Director, RHEL and modern data center technologies like Cisco UCS and Cisco Nexus 1000v and NSX. If you find any post informational to you please press like and share it across social media and leave your comments if you want to discuss further on any post. Disclaimer: All the information on this website is published in good faith and for general information purpose only. I don’t make any warranties about the completeness, reliability and accuracy of this information. Any action you take upon the information you find on this blog is strictly at your own risk. The Views and opinions published on this blog are my own and not the opinions of my employer or any of the vendors of the product discussed.
This entry was posted in Linux/CentOS, SSH. Bookmark the permalink.

21 Responses to SSH RSA host key has just been changed

  1. blogg.Asia says:

    Thanks for sharing your thoughts about lifelong. Regards

    Like

  2. Hier Klicken says:

    Unquestionably imagine that that you stated. Your favourite reason appeared to be at
    the net the simplest thing to take into account
    of. I say to you, I definitely get irked while folks think about issues that they plainly don’t recognise about.
    You managed to hit the nail upon the highest and also defined out the entire thing
    without having side effect , folks can take a signal. Will likely be back
    to get more. Thanks

    Like

  3. Santosh Kumar says:

    Manually Editing
    vi ~/.ssh/known_hosts

    #Removing the confilcting host key

    and remove

    Like

  4. It’s remarkable in favor of me to have a website, which is useful for my know-how.

    thanks admin

    Like

  5. I will right away take hold of your rss as I can’t in finding your email subscription link or
    newsletter service. Do you’ve any? Please allow me know so that I may subscribe.
    Thanks.

    Like

  6. I have been browsing online more than 3 hours lately, yet I by no means found any fascinating article like yours.
    It is pretty price sufficient for me. Personally, if all webmasters and bloggers made excellent content as you did, the
    net will be much more helpful than ever before.

    Like

  7. I enjoy what you guys are up too. This sort of clever work
    and exposure! Keep up the good works guys I’ve incorporated you
    guys to blogroll.

    Like

  8. social media says:

    If some one wishes to be updated with newest technologies
    then he must be go to see this website and be up to date every day.

    Like

  9. Carolina says:

    Hi there, I enjoy reading all of your article.
    I like to write a little comment to support you.

    Like

  10. Maria says:

    This piece of writing will assist the internet users
    for setting up new weblog or even a weblog from start to
    end.

    Like

  11. you are in reality a just right webmaster. The web site loading velocity is incredible.
    It seems that you are doing any unique trick. Furthermore, The contents are masterwork.
    you’ve done a fantastic activity in this matter!

    Like

  12. website says:

    I’ve read some just right stuff here. Definitely
    value bookmarking for revisiting. I surprise how so much attempt you put to create
    such a excellent informative site.

    Like

  13. alexhunt says:

    thanks website.

    Like

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s