Verifying public key fingerprint through ssh-keyscan, and ssh-keygen

2022 16Apr 24Sun 1945hrs Avril vingt-quatrième Dimanche dix-neuf : quarante-cinq

When a ssh login to a remote machine was attempted for the very first time the message that was given from the remote machine to the local machine’s terminal was to identify the key. Instead of giving out the public key itself, it gives out a public key’s fingerprint.

Instead of identifying the verity of the remote machine the very moment one needs to make an ssh login, it would be helpful to identify the remote machine’s key in advance. To do so, one uses the ssh-keyscan.

ssh-keyscan remoteID@remoteMachine

This gives out the remote machine’s public key information, instead of giving out the key’s fingerprint.

The fingerprint needs to be checked out independently. Once you are given the public key information make it as a text file, <publicKeyText>.

ssh-keygen -lf <publicKeyText>. # the result will give you the fingerprint of the key.

When making the text file make sure to include the whole line that the remote machine has given when asked through ssh-keyscan.

To shorten the steps,

ssh-keyscan -t keyType remoteID@remoteMachine | ssh-keygen -lf –