Thursday, September 1, 2011

ssh host id changed

Don't you hate when this happens?



$ ssh some.host.com
@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Please contact your system administrator.
Add correct host key in /home/ansilva/.ssh/known_hosts to get rid of this message.
Offending key in /home/ansilva/.ssh/known_hosts:295
RSA host key for some.host.com has changed and you have requested strict checking.
Host key verification failed.


Instead of opening known_hosts, look for line, and delete host, save file... here's what you can do:

$ ssh-keygen -R !$
ssh-keygen -R some.host.com
/home/remote/ansilva/.ssh/known_hosts updated.
Original contents retained as /home/remote/ansilva/.ssh/known_hosts.old
There we go:

$ ssh some.host.com
The authenticity of host ' some.host.com ()' can't be established.
RSA key fingerprint is XXXXXXXXXX.
Are you sure you want to continue connecting (yes/no)?

1 comments:

ਇੰਦਰ ਪੁੰਜ਼ said...

I really love this command :-) It saved my ~5 mins