linuxMisc

darn…my SSH key changed ?

Have you recieved the below message when you try to ssh or sftp to a UNIX/LINUX server ?   I hate when it happens while trying to do something really quick. Well I found a easy  way to fix it  if you have proper access.

I got this error while trying to sftp to the server spiderweb

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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
xx:e3:0f:xx:yy:yy:xx:5b:60:hh:4b:xx:52:xx:xx:b4.
Please contact your system administrator.
Add correct host key in /home/spider/.ssh/known_hosts to get rid of this message.
Offending key in /home/spider/.ssh/known_hosts:2
RSA host key for spiderweb has changed and you have requested strict checking.
Host key verification failed.
Connection closed

Solution  1 :
vi or pico the /home/spider/.ssh/known_hosts file and delete the offending key.  The file is going to look like this :

spiderweb,101.451.126.15 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuM5jmqpIlTG/
APbzYZU31lsTWy9qGevF2XQABwJhNz0niLqkXSThlYx8yDkMor6XkReHY4OR9SPeAzs3hPQn
AH7GT/yqqMstmVOrF6W1+2sQ3Aymdu5jItE9t0+pL6pasyd9ZJhlKDDo02dpt13ooW3XyTl

iceman,114.16.15.140 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAukZikbzoto7
GG1CAHu5S7I5m2VlwjdERi6sO7Do/yHQdf1xRHY917LHHHLlmg5YM5i8sDkjU5y3b1vNz7
O4iIvvkDAYUTT80uOoqFBNQsKxMhlHmy5RqKwSpP5kmkNun0gXOynj9RF+iZsL0obiphDj

If you want to reset the ssh key all you have to do is remove the entry for the server spiderweb. Delete the lines I have hightlited in blue and save. When do sftp or ssh next time, the server will update the file with a new ssh key.

Solution 2:
Contact your system administrator as the message says and he will do either the same for you or change the strictness.