Obtain fingerprints for all ssh-rsa keys in authorized_keys file

I have an single authorized_keys file with about 50 public keys in it. I would like to periodically obtain the key fingerprints for each of those to cross-reference against a log file. Is there a utility (or a series of utilities)  to export this information? Doesn't need to be batch-friendly, a GUI would be fine if that's all there is available.

Environment: Win 2003 server SP2, copssh 2.1.0 (cygwin1.dll v1.5.25)

"ssh-keygen -l -f keyfile" does not work - it just gives me a single hash.

team170Asked:
Who is Participating?
 
Dave HoweConnect With a Mentor Software and Hardware EngineerCommented:
there is no trivial command to do this - however, you can easily write a small bit of script.

consider the following:
cat ~/.ssh/authorized_keys | while read a b c
do
echo $a $b $c > tmp_auth_key
ssh-keygen -lf tmp_auth_key | sed "s/tmp_auth_key/$c/"
done
rm tmp_auth_key

Open in new window

0
 
Dave HoweSoftware and Hardware EngineerCommented:
oh, and in case you are wondering, the sed bit is there to convert the file name into the key comment in the output, for readability :)
0
 
team170Author Commented:
Worked great, thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.