Skip to content

Instantly share code, notes, and snippets.

@hvr
Created November 4, 2010 07:02
Show Gist options
  • Save hvr/662196 to your computer and use it in GitHub Desktop.
Save hvr/662196 to your computer and use it in GitHub Desktop.
Show key fingerprints of public keys in .ssh/authorized_keys file
#!/bin/bash
( while read L
do echo $L > /tmp/pubkey
printf "%-16s => " $(cut -f 3 -d ' ' /tmp/pubkey)
ssh-keygen -l -f /tmp/pubkey
done
rm /tmp/pubkey
) < .ssh/authorized_keys
@dinomite
Copy link

I have some comments & blank lines in my authorized_keys file, so I added a check to ignore those.

#!/bin/bash
IGNORE_LINES="^#|^$"

( while read line
do echo $line> /tmp/pubkey
    if [[ "$line" =~ $IGNORE_LINES ]]
    then
        continue
    fi
    printf "%-16s => " $(cut -f 3 -d ' ' /tmp/pubkey)
    ssh-keygen -l -f /tmp/pubkey
done
rm /tmp/pubkey
) < $HOME/.ssh/authorized_keys

@tobijb
Copy link

tobijb commented Aug 8, 2013

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment