"Host key verification failed" error when transfering files using SCP command [duplicate]
Solution 1:
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.
Solution 2:
You have to remove the 4th ssh key from /home/users/myaccount/.ssh/known_hosts
file.
Solution 3:
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.