Skip to content

Instantly share code, notes, and snippets.

@realitygaps
Created October 21, 2014 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save realitygaps/f7ce97d0de7dbcfbcbeb to your computer and use it in GitHub Desktop.
Save realitygaps/f7ce97d0de7dbcfbcbeb to your computer and use it in GitHub Desktop.
Import and sign keys (from the current directory)
#!/usr/bin/env bash
#############################################################################
# #
# Import all the pub keys in this folder and sign them with your priv key #
# #
#############################################################################
# get the keyfiles in a string
keys=`ls *.asc`
# import (new) keys in gpg
gpg2 --import $keys
privkeys=`gpg2 --list-secret-keys`
# find my privkey in this list
for key in $keys
do
cleankey=${key%%.asc}
if [[ -n `echo $privkeys | grep ${cleankey##0x}` ]]
then
mykey=$cleankey
fi
done
if [[ -z $mykey ]]
then
echo 'Your key was not found in store'
exit 1
fi
# locally sign pubkeys keys with my privkey
for key in $keys
do
gpg2 --sign-with $mykey --lsign-key ${key%%.asc}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment