Display the default fingerprint#
Of a key#
You can either use the public key or private key to obtain the fingerprint (default is SHA256 in base64).
ssh-keygen
option:
-f filename
Specifies the filename of the key file.-l
Show fingerprint of specified public key file.
Of a ssh server key#
When you connect to a machine for the first time, you do not have the fingerprint of the server key in your known_hosts
, so ssh has nothing to compare it to, so it asks you to check it manually.
Display fingerprint in other formats#
Of a key#
You can also display the fingerprint using another algorithm (here md5 in hexadecimal).
ssh-keygen
option:
-E fingerprint_hash
Specifies the hash algorithm used when displaying key fingerprints. Valid options are: "md5" and "sha256". The default is "sha256".
Of a ssh server key#
You can also do the same when you connect to a server:
ASCII Art representation#
You can use hashes to check a server or a key fingerprint programmatically but when you want to check by eye it is easier to compare an ASCII Art representation.
Of a key#
To display the ASCII art representation just add the -v
option after the -l
one.
ssh-keygen
option:
-l
If combined with-v
, a visual ASCII art representation of the key is supplied with the fingerprint.
Of a ssh server key#
With ssh
the option is -o VisualHostKey=yes
:
Fingerprint via DNS#
It is possible to put the fingerprint in DNS and get ssh
to ell you if what it the two fingerprints match.
Configure DNS#
You can use ssh-keygen
to display the new entries you need to add to your DNS server.
-r hostname
Print the SSHFP fingerprint resource record named hostname for the specified public key file.-g
Use generic DNS format when printing fingerprint resource records using the-r
command.
Manually check DNS entries#
You can check SSHFP
records using drill
(dig
replacement).
Automatic check with ssh#
To make ssh
check if the ssh fingerprint match the one displayed in the DNS record you can use the -o VerifyHostKeyDNS=ask
option.
Or add VerifyHostKeyDNS ask
in /etc/ssh/ssh_config
.
Go deeper#
The Algorithm Number 1 is for RSA, 2 is for DSS (DSA), 3 is for ECDSA and 4 is for Ed25519. The Fingerprint Type type 1 is for SHA-1 and type 2 is for SHA-256.
- RFC 4255 - Using DNS to Securely Publish Secure Shell (SSH) Key Fingerprints
- RFC 6594 - Use of the SHA-256 Algorithm with RSA, Digital Signature Algorithm (DSA), and Elliptic Curve DSA (ECDSA) in SSHFP Resource Records
- RFC 7479 - Using Ed25519 in SSHFP Resource Records