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:
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
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 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
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:


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/^*n//;' ~/.ssh/known_hosts
Substitute your actual domain for 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.
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
Posted in: Linux.
Last Modified: January 12, 2017

21 thoughts on “SSH RSA host key has just been changed

  1. Hier Klicken

    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

  2. Santosh Kumar

    Manually Editing
    vi ~/.ssh/known_hosts

    #Removing the confilcting host key

    and remove

    1. Santosh Kumar

      Woderful Job done to help guys like us.

    2. alexhunt86 Post author

      Santosh bhai kuch badhiya topic mile toh batana jo upload kiya ja sake ispe.

  3. psn code generator

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

    thanks admin

    1. alexhunt86 Post author

      Its give me immense pleasure to share whatever knowledge I have gained with others.


    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.


    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.

    1. alexhunt86 Post author

      It gives me a lot of happiness when I found that articles shared by me is of any use to other people. This motivates me further.

  6. social media

    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.

    1. alexhunt86 Post author

      Thanks for your praise. I will keep posting new things that can help people in any way.

  7. Carolina

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

    1. alexhunt86 Post author

      Thanks carolina. Support of you guys motivate people like us to post more and more information which can help people round the globe.

  8. Maria

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


    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!

  10. website

    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.

Leave a reply