Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Host Key Verification Failed

Tags:

ssh

ubuntu

host

I'm trying to ssh into my UBUNTU through my PC with Cygwin on it. I can WINSCP without a hitch, however when I ssh through a command line it comes up with this error:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
5d:84:de:4e:a8:81:df:22:06:23:98:34:cd:26:f5:1a.
Please contact your system administrator.
Add correct host key in /home/Trevor/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/DIRECTORY
ECDSA host key for HOSTNAME has changed and you have requested strict checking.
Host key verification failed.

So I looked it up and it said that I needed to change my host key in my .ssh folder that's located in my home folder. Well, there wasn't one so I made one. Tried again and got the same error.

What to do?

like image 967
user1985351 Avatar asked Sep 26 '13 02:09

user1985351


People also ask

How do I fix host key verification failed?

To fix this error, we need to delete the offending key from the “known_hosts” file present in our system in “. ssh” directory. The error gives you the remote server's IP address and the line number on which the key is stored in the “known_hosts” file.

What does host key verification failed mean?

This error occurs when the target server you are trying to SSH into has been rebuilt or had it's RSA key changed since the last time you connected to it.

What is host key verification?

In host key checking, ssh automatically maintains and checks a database containing identification for all hosts it has ever been used with. Host keys are stored in ~/. ssh/known_hosts in the user's home directory. Additionally, the /etc/ssh/ssh_known_hosts file is automatically checked for known hosts.

How do I remove host key verification?

You need to create a ~/. ssh/config file and disable strict host key checking by adding the content. This will disable host checking for all hosts you connect to. Rather than disabling host check for all Host “*”, it would be safer to specify a particular host.


3 Answers

"Host key verification failed" means that the host key of the remote host was changed.

Ssh stores the host keys of the remote hosts in ~/.ssh/known_hosts. You can either edit that text file manually and remove the old key (you can see the line number in the error message), or use

ssh-keygen -R hostname 
like image 141
Suhas.s Avatar answered Sep 18 '22 23:09

Suhas.s


try

 rm -f /home/user/.ssh/known_hosts

or deletes the offending key from the known_hosts

ssh-keygen -R hostname
like image 33
Gabber Avatar answered Sep 18 '22 23:09

Gabber


This generally means that the host key of your remote host has been changed. It can be used to avoid the men in the middle attacks and to make your host secure. You can simply remove this using:

ssh-keygen -R hostname | ip address 

or

ssh-keygen -f "/root/.ssh/known_hosts" -R ip address
like image 32
Saboor Avatar answered Sep 18 '22 23:09

Saboor