Sample output
256 SHA256:ntaLSnHJ9i9RDaN2l8O/76jgtbhhcs6YwTnMhzhzSJI ada@laptop (ED25519)
3072 SHA256:otA3tNjmlfFG+gAlyt2+YO13UJl5Cz/tJxtFp13A7H4 deploy@ci (RSA)
256 SHA256:wRY+6GdGFlzFrrOrahDlUeUVXrh42/r/K5PvJdEPwQc old key, do not use (ECDSA)
Three keys can log in to this account. The columns are key size in bits, fingerprint, the comment from the end of the line, and the key type. The third one has a comment asking not to be used, which is not the same as being removed. Delete that line from authorized_keys and it stops working on the next login attempt.
When you would reach for it
Someone left the team and you need to know whether their key still opens the production box. A deploy started working from a machine nobody recognizes and you want to match the fingerprint in the auth log to a line in the file. Or you inherited a server and want an inventory of who can get in before you change anything. The raw file answers none of these at a glance; one fingerprint per line does.
Gotchas
- The comment is whatever the key’s creator typed, or whatever
user@hostnamewas when they ranssh-keygen. It proves nothing. Match on the fingerprint, which comes from the key itself, and treat the comment as a hint. - A line that is not a valid key is skipped without a warning, and the exit status is still 0. A truncated paste disappears from the output, so the file can hold more lines than you see. Compare against
grep -c '^[^#]' ~/.ssh/authorized_keysif the count matters. Blank lines and comments are skipped the same way. - Pointed at
~/.ssh/known_hosts, the comment column shows the host name, unless the file is hashed. Debian turns onHashKnownHostsin/etc/ssh/ssh_config, so there you get|1|I+XtPGlG...where the name should be. Usessh-keygen -lF hostname(below) to look up one host instead. - Older tools and some cloud consoles still show MD5 fingerprints like
aa:be:79:11:.... Those are the same key with a different hash, not a different key. Add-E md5to compare like with like. - On Alpine,
ssh-keygenlives in its ownopenssh-keygenpackage, separate from the client. macOS 15 and Debian 12 ship it with OpenSSH.
Variants
$ ssh-keygen -lF github.com
Print the fingerprint known_hosts has stored for one host, hashed file or not. Compare it with the fingerprint the provider publishes before you trust it
$ ssh-keyscan -t ed25519 github.com | ssh-keygen -lf -
Fingerprint the key a server presents right now, without connecting. -f - reads from stdin, so the pipe hands over the key without a temp file. ssh-keyscan prints its banner comments to stderr, and they show up above the result
$ ssh-keygen -E md5 -lf ~/.ssh/id_ed25519.pub
Your own key in the old MD5 format, for the dashboards that still display it that way