Search This Blog

Wednesday, May 22, 2013

Add correct host key in ~/.ssh/known_hosts

Error: Add correct host key in /home/boss/.ssh/known_hosts to get rid of this message.
Offending key in /home/boss/.ssh/known_hosts:1
RSA host key for 202.141.151.19 has changed and you have requested strict checking.
Host key verification failed.

Solution:
  1. get the rsa key of your server:

    $ ssh-keyscan -t rsa server_ip  # server_ip SSH-2.0-OpenSSH_4.3  server_ip ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwH5EXZG...  
  2. and on the client, add this key to ~/.ssh/known_hosts:

    server_ip ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAqx9m529...(the offensive key)  server_ip ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwH5EXZG...