Friday, December 12, 2014

How to verify you are connecting to right host using ssh

You tried to connect to host name webserver1 and you got a confirmation message like below
The authenticity of host 'webserver1.example.com (10.17.10.16)' can't be established.
RSA key fingerprint is 74:78:10:04:95:3e:c5:d9:b3:fb:50:f2:05:9b:87:bc.
Are you sure you want to continue connecting (yes/no)?

How to verify that you are connecting to right host and man in the middle attack is not redirecting you to wrong host to get your credentials.

On the destination server run the following command

#ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key
2048 74:78:10:04:95:3e:c5:d9:b3:fb:50:f2:05:9b:87:bc /etc/ssh/ssh_host_rsa_key.pub (RSA)

If the output hash matches with the prompt hash message then you are connecting to the right host.