sometimes when connecting to a computer with SSH, things can get jumbled up and an erroneousness can occur that looks 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:1
RSA host key for has changed and you have requested strict checking.
Host key verification failed.

The function of the known_hosts file is for the client to authenticate the waiter they are connecting to. This error will occur when the public key the host has changes.To fix this we must remove the key causing the error .

Linux / Mac / Windows with MobaXterm

Finding the known_hosts File:

After you have connected to a computer using ssh, the key you used to connected is stored in a file called known_hosts which is located in a hidden file ( .ssh ) in your family directory. It can be opened in a text editor program of your choice with :

[abc123@computer ~]vim ~/.ssh/known_hosts

You will notice the file is arranged : computer name, ip-address veryLongKey, where each trace is its own calculator and key. If you have a smaller sieve the key will continue on to the future line, but is however counted as one line.

Method 1 – Getting Rid of It All

If you merely have one host in your know_host file then removing the stallion file is a solution. The file will be recreated the future time you ssh into that calculator. Before you remove the charge you should back up the contents :

cp ~/.ssh/known_hosts ~/.ssh/known_hosts.old
[abc123@computer ~]rm ~/.ssh/known_hosts

Method 2 – Targeting the Key Individually

If you look at the error message you will notice this line :

RSA host key for has changed...

This tells which is the offending host, then now you can remove that key by running :

[abc123@computer ~]ssh-keygen -R HOSTNAME

This will give you the following output signal when it is successful :

# Host HOSTNAME found: line #
/home/user/.ssh/known_hosts updated.
Original contents retained as /home/user/.ssh/known_hosts.old

You can besides edit the known_hosts file immediately and remove the entire shock line which is indicated by : Offending key in /home/user/.ssh/known_hosts:1. In this case the line is 1. You may end up deleting something you did not intend to so back the file up first :

cp ~/.ssh/known_hosts ~/.ssh/known_hosts.old

Windows with PuTTY

Unlike the other options above, PuTTy does not create a convenient known_hosts folder in your home directory. alternatively we need to edit the register it creates :

  1. Search for regedit.exe and open it
  2. Navigate to HKEY_CURRENT_USER/SOFTWARE/SimonTatham/PuTTy/SshHostKeys
  3. Right click the offending key and click delete

If there are any far questions, or there is an emergence with the software documentation, please contact rc-help @ for extra aid .

reservoir :
Category : Website hosting

Leave a Reply

Your email address will not be published.