19

When I am trying to transfer files using SCP command I'm getting this error (Removed my IP and RSA key):

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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
------------------------(RSA key)
Please contact your system administrator.
Add correct host key in /home/users/myaccount/.ssh/known_hosts to get rid of this message.
Offending key in /home/users/myaccount/.ssh/known_hosts:4
RSA host key for 'my IP' has changed and you have requested strict checking.
Host key verification failed.
lost connection

I am using newly installed Ubuntu 12.04 and I can connect to this server using ssh. Any help?

0

3 Answers 3

16

This can easily happen when connecting to a computer who's host keys in /etc/ssh have changed if that computer was upgraded without copying its old host keys. The host keys here are proof when you reconnect to a remote computer with ssh that you are talking to the same computer you connected to the first time you accessed it.

If the remote computer is within your control you probably know if it was updated and the host keys not copied. If so, and if the system is on your LAN you can be pretty safe in ignoring or circumventing this error message. You probably know its IP address with certainty and know there are no trojan devices on it.

If the computer is not within your control but you are certain that it has been upgraded it may also be reasonable to circumvent this error message. (If the remote host publishes the hashes of its ssh host keys you may be able to check these to be safer, or you can call the server's management to obtain the host key fingerprint).

If the computer is within your control you should copy the old host keys from /etc/ssh to the new system as part of your upgrade procedure. (N.B. there are both key files and configuration files in this directory.)

Once you know you want to ignore this condition there are at least 2 ways to deal with this issue.

  • Pass the StrictHostKeyChecking in the SSH command such as (example) :

ssh -o 'StrictHostKeyChecking no' user@host

You'll have to do this each time. Or ...

  • Remove the offending ssh key (real example taken from your answer) :

sed -i '4d' /home/users/myaccount/.ssh/known_hosts

This is the more permanent solution. Instead of giving you the above message you will be given the option to accept the new hostkey from the server, just as you did the very first time you connected to it. Verify the best you can that you are connecting to the correct remote computer, without going through an intermediary, and then accept the new host key.

0
11

You have to remove the 4th ssh key from /home/users/myaccount/.ssh/known_hosts file.

0
1

It seems that you copied your ssh-folder from an old system to your new one.

Open terminal and type in:

rm /home/USERNAME/.ssh/known_hosts

This will delete all the "old" keys.

2
  • 3
    Instead of all, a safer way is to only remove the target host related keys via ssh-keygen -R hostname.
    – Bowen Xu
    Oct 6, 2019 at 10:18
  • The location of known_hosts on ein10 is a bit different compare to Linux systems. The file is located at C:\Users\<USERNAME>\.ssh\known_hosts . Aug 22, 2021 at 20:20

Not the answer you're looking for? Browse other questions tagged .