My laptop has a well-populated ~/.ssh/known_hosts file. I'd like to leverage that when connecting to remote hosts from my desktop, since tracking down the fingerprints can be a real chore. However, I can't seem to find a way to ask ssh-keygen or ssh-keyscan to tell me the locally-known fingerprint for known hosts. Any ideas?
Asked
Active
Viewed 3.2k times
91
Sirex
- 11,060
1 Answers
120
Try this command:
% ssh-keygen -l -f ~/.ssh/known_hosts
2048 c2:e7:c0:9f:cd:c8:54:88:ac:b3:6b:a6:51:73:2b:e3 mach1,192.168.1.3 (RSA)
2048 a2:5e:8c:4e:2e:be:be:eb:23:12:5e:fe:6c:4b:23:dd mach2,192.168.1.1 (RSA)
1024 ae:5f:bc:e3:33:c3:dd:45:1e:18:1a:46:d1:d6:d2:39 mach3,192.168.1.6 (RSA)
...
...
just want a single host:
% ssh-keygen -l -f ~/.ssh/known_hosts -F mach1
2048 c2:e7:c0:9f:cd:c8:54:88:ac:b3:6b:a6:51:73:2b:e3 mach1 (RSA)
Resources
slm
- 10,249
-lwith a known_hosts file.Here's a version that even better addresses my question:
– Tim has moved to Codidact Jan 21 '13 at 02:10ssh-keygen -l -f ~/.ssh/known_hosts -F example.com-E md5option. – a172 Sep 08 '15 at 15:08[example.com]:1234– Tim has moved to Codidact May 07 '16 at 21:04ssh-keyscan 123.123.12.34 | ssh-keygen -l -f -– TrinitronX Feb 14 '18 at 01:24