Created
October 21, 2014 14:26
-
-
Save realitygaps/f7ce97d0de7dbcfbcbeb to your computer and use it in GitHub Desktop.
Import and sign keys (from the current directory)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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