View ~/.ssh/known_hosts key information

ssh-keygen -l -f ~/.ssh/known_hosts
Will return the SSH server key information for each host you have in your ~/.ssh/known_hosts file, including key size, key fingerprint, key IP address or domain name, and key type.
Sample Output
2048 33:3c:db:04:96:f8:c0:dc:3b:c5:eb:8a:29:32:90:74 (RSA)
2048 1f:5c:f1:0f:6a:77:b8:ab:22:13:6f:9f:4e:16:1f:b9 (RSA)
2048 3a:01:a8:a1:23:cd:73:0d:7e:1e:bf:70:da:a0:e9:ab (RSA)
2048 16:7a:81:3a:96:6a:65:a5:b6:37:15:35:c0:09:56:e4 (RSA)
2048 a1:5b:b8:10:86:4b:6f:5d:d8:77:d3:da:a0:ce:0d:3f (RSA)
2048 0e:4d:d6:09:95:97:29:94:9f:59:78:e8:59:65:83:60 (RSA)
2048 d9:fc:1d:46:63:57:f7:07:54:23:bf:88:af:3a:4a:71 (RSA)
2048 7b:81:21:60:27:63:a4:38:34:42:08:22:70:16:19:70 (RSA)

By: atoponce
2010-12-05 04:03:07

What Others Think

Add "|sort -k 2" at the end. That way it groups the information per server. I have two entries for most servers. One only IP adress and one also the domain name.
houghi · 549 weeks and 3 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: