You can generate a fingerprint for a public key using ssh-keygen
like so:
ssh-keygen -lf /path/to/key.pub
Concrete example (if you use an RSA public key):
$ ssh-keygen -lf ~/.ssh/id_rsa.pub
2048 00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff /Users/username/.ssh/id_rsa.pub (RSA)
The first part (2048)
is the key length in bits, second part (00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff)
is the fingerprint of the public key and the third part is location of the public key file itself.
In newer versions of OpenSSH, Base64 encoded SHA-256 is shown instead of hexadecimal MD5. To show the legacy style hash, use
$ ssh-keygen -l -E md5 -f ~/.ssh/id_rsa.pub
8"...be cautious and double check that you're actually connecting to the correct host over a secure connection" -- stupid question, but how can you do this easily? – Savara – 2015-08-10T11:00:33.443
4@Savara When you are connecting to an SSH server which you did not connect before, you should request the public key of the SSH server from the server admin. The server admin will give you a piece of text. You should append this text to the file
~/.ssh/known_hosts
. This way, when you connect to the server, your SSH client will recognize this server, since you have saved its public key toknown_hosts
. Hence, actually you should never say "yes" when the SSH client tells you "The authenticity of the host cannot be established". You should always add the public key of the server beforehand. – Utku – 2017-03-24T16:06:27.353@Savara If you do this, you will know that something fishy is going on when your SSH client tells you "The authenticity of the client cannot be established" or when it tells you "The public key of the server has been changed". Hence, you should always add the public key of the server to your
~/.ssh/known_hosts
file beforehand and never say yes when your SSH client tells you "The authenticity of the client cannot be established" or when it tells you "The public key of the server has been changed". – Utku – 2017-03-24T16:09:35.2333Yeah, I'm fully aware of how the mechanics of viewing SSH fingerprints works, but a large percentage of the time you don't have the option to get the fingerprint through another channel. TOFU is sadly the best we often get. – Savara – 2017-03-25T17:55:52.687
Is there a way to check the authenticity even after answering "yes"? – exchange – 2018-03-03T11:27:01.440
Found this link where one can backcheck the fingerprint of github, maybe it helps? https://help.github.com/articles/github-s-ssh-key-fingerprints/
– exchange – 2018-03-03T12:17:38.077