Skip to content

Instantly share code, notes, and snippets.

@thcipriani
Created July 28, 2017 15:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thcipriani/b81be4f125a07cae9825dc42bf2a7176 to your computer and use it in GitHub Desktop.
Save thcipriani/b81be4f125a07cae9825dc42bf2a7176 to your computer and use it in GitHub Desktop.
A gpgparticipants(1) helper script. The idea is to not import the keys you have initially, but only after the ksp-file.txt has been verified as correct.
#!/usr/bin/env bash
set -euo pipefail
help() {
cat<<HELP 2>&1
USAGE:
ksphelper <party name> <keymaster> <keysfile>
ksphelper helps create a gpgparticipants file from a list of keys.
Outputs a ksp-text.txt in the current directory from gpgparticipants
and won't mess with your normal gpg keyring to do it.
OPTIONS:
<party name> Name for your keysigning party, passed as title to
gpgparticipants(1)
<keymaster> KSP organizer in the format: "Name <email@domain.tld>",
passed as organizer to gpgparticipants(1)
<keysfile> Path to text file that contains the keys of all
participants, one per line, comments and blank lines
are ignored.
EXAMPLE:
ksphelper "WMFRelEng" "Tyler Cipriani <tcipriani@wikimedia.org>" keys
HELP
}
if (( $# < 3 )); then
help
exit 1
fi
KSP_NAME="$1"
KEYMASTER="$2"
KEYS_FILE="$3"
KEYRING_DIR="$(mktemp -d -q --suffix=_ksphelper)"
KEYRING="pubring.kbx"
touch "${KEYRING_DIR}/${KEYRING}"
# Grab all the keys into a local keychain
grep -v '^#' keys | \
grep -v '^\s*$' | xargs gpg \
--no-options \
--no-default-keyring \
--keyring="${KEYRING_DIR}/${KEYRING}" \
--recv-keys
grep -v '^#' keys | \
grep -v '^\s*$' | GNUPGHOME="$KEYRING_DIR" gpgparticipants \
- ksp-file.txt "$(date --iso=seconds)" "$KEYMASTER" "$KSP_NAME"
rm -rf "$KEYRING_DIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment