Skip to content

Instantly share code, notes, and snippets.

@eminaksehirli
Created February 13, 2015 22:41
Show Gist options
  • Save eminaksehirli/6942929d3a2fd0a3dbdb to your computer and use it in GitHub Desktop.
Save eminaksehirli/6942929d3a2fd0a3dbdb to your computer and use it in GitHub Desktop.
Finds the signatures on PGP keys. More info on http://memin.tk/informatics/2015/01/29/key-upgrade.html
#!/bin/bash
MyKey=90D39AD1
I_SIGN_FILE=/tmp/i_signed.txt
I_SIGN_FILE_SORTED=/tmp/i_signed_sorted.txt
SIGNED_ME_FILE=/tmp/signed_me.txt
gpg --list-keys |grep "^pub"|grep -v revoked|grep -v expired|sed -e "s#.\+/\([0-9A-F]\+\) .\+#\1#" > /tmp/keyring.txt
if [ -e $I_SIGN_FILE ]; then
echo "File $I_SIGN_FILE exists. It may cause problems, please delete it if you don't need it."
exit 1
fi
for KEY in `cat /tmp/keyring.txt`
do
gpg --list-sigs $KEY|grep -q $MyKey
SIGNED=${PIPESTATUS[1]}
if test $SIGNED == 0; then
echo $KEY >> /tmp/i_signed.txt
fi
done
sort /tmp/i_signed.txt |uniq > $I_SIGN_FILE_SORTED
gpg --list-sigs $MyKey |grep "^sig"|sed -e "s#.\+\([0-9A-F]\{8\}\) [0-9]\{4\}-.*#\1#" |sort|uniq > $SIGNED_ME_FILE
comm -12 $I_SIGN_FILE_SORTED $SIGNED_ME_FILE > /tmp/mutual.txt
comm -23 $I_SIGN_FILE_SORTED $SIGNED_ME_FILE > /tmp/only_i.txt
comm -13 $I_SIGN_FILE_SORTED $SIGNED_ME_FILE > /tmp/only_they.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment