Fix the SSH “Remote Host Identification Has Changed” Error in Ubuntu

If you are trying to access any ubuntu machine through ssh and you are getting the error  "Remote Host Identification Has Changed".

Every SSH server uses a random key to identify itself. When SSH is installed a new key is generated. SSH clients keep track of the host key, if it changes the user can be warned that they might not be connecting to the computer they think they are. Most of the time this happens when the SSH server or the OS are reinstalled.
When we reinstall an user's laptop this error might occur when we try to ssh.


The error looks 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
e4:43:27:5d:ad:8f:e8:fb:e7:af:5e:a0:26:6d:a1:dd.
Please contact your system administrator.
Add correct host key in /home/esoumis/.ssh/known_hosts to get rid of this message.
Offending key in /home/esoumis/.ssh/known_hosts:6
RSA host key for 72.43.222.229 has changed and you have requested strict checking.
Host key verification failed.
Solution to the error:
  1. The version of SSH installed in Ubuntu does not produce a known_hosts file that is easily readable. The easiest way to fix the problem is to delete the known_hosts file:
    rm ~/.ssh/known_hosts 

    (Not recommended as all other known hosts entries will also get removed)
  2. Notice the highlighted line in the error message above, the “6” in the end is the line number.
    vi /home/esoumis/.ssh/known_hosts

    :{line number}
    dd  (dd = delete line)
    :w
    q!
  3. vi /home/esoumis/.ssh/known_hosts
    :6
    dd  (dd = delete line)
    :w
    q!
     
    4.  sed -i (line number)d .ssh/known_hosts 
         sed -i 6d .ssh/known_hosts 
  
    5. Lastly, if you know the hostname, you can remove entries for that hostname in either of  the following ways


$ ssh-keygen -R {server.name.com}
$ ssh-keygen -R {ssh.server.ip.address}
$ ssh-keygen -R server.example.com

eg: $ ssh-keygen -R 1RQGVQ1.egi.ericsson.com
Output:

 /home/esoumis/.ssh/known_hosts updated.
 Original contents retained as /home/esoumis/.ssh/known_hosts.old
After trying any of the above steps, the next time you run “ssh”, it will make a new “known_hosts” file and add the entry(if you have followed step-1), or add the new entry to the existing “known_hosts” file.



Related

open source 1031729947932589982

Post a Comment

  1. This piece of writing is truly a good one it helps new net viewers,
    who are wishing in favor of blogging.

    Feel free to surf to my blog book of ra cheats - ,

    ReplyDelete

emo-but-icon

 

Recent Posts

comments

Join Us

 

Recommended

item