2009-05-19

ssh - error "Host key verification failed" when trying to connect or copy a file to ssh server

The below error was display while trying to ssh or scp to a ssh server :










@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@       WARNING: POSSIBLE DNS SPOOFING DETECTED!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The RSA host key for domain-name.com has changed,
and the key for the according IP address xxx.xxx.xxx.xxx
is unknown. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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
00:00:00:00:00:00:00:00:00:00:00:00:.
Please contact your system administrator.
Add correct host key in ~/.ssh/known_hosts to get rid of this message.
Offending key in ~/.ssh/known_hosts:xx
RSA host key for domain-name.com has changed and you have requested
strict checking.
Host key verification failed.
lost connection

Of cause the connection ended unsuccessfully. If you read the error message carefully, it might intimate you by meaning someone is meddling your ssh session (man in the middle attack aka monkey in the middle). But commonly (at least to the author), it is due to the ssh session generated a different RSA key to the previous one recorded at ~/.ssh/known_hosts:<line number>.

The solution? Delete the line of the file mentioned "Offending key in ~/.ssh/known_hosts:<line number>". Re-connect it and all will be fine.

Voilla !!!

No comments: