Personal PGP key utilities. Small scripts for the operations I always have to look up in the GPG manual, wrapped so they're safe and repeatable.
Works on a file (not on your ~/.gnupg keyring — it uses a disposable
GNUPGHOME that's cleaned up on exit). Extends the primary key and all
subkeys, then pushes the updated public key to the listed keyservers
(unless --no-publish is given).
./extend-key.sh --help # full usage
./extend-key.sh key.asc # extend for 2y (default), publish to default keyservers
./extend-key.sh -e 5y key.asc # extend for 5 years
./extend-key.sh --no-publish key.asc # extend locally only, don't touch keyservers
The passphrase is read from $PGP_PASSPHRASE or prompted interactively.
Never pass the passphrase on the command line — CLI args are visible to
other users via ps.
# Drop into the dev shell (Nix flake or direnv)
nix develop
# or, with direnv installed:
direnv allow
# Run the test suite (generates a throwaway fixture key, no real keys used,
# no network)
./test/test-extend-key.sh
# Lint
shellcheck extend-key.sh test/test-extend-key.sh- The script uses
mktemp -d+chmod 700+trapto keep the temporary GPG homedir isolated and cleaned up — even if it crashes or isCtrl+C'd. - The output file is written with
umask 077so it's readable only by the current user. - The passphrase is never logged, never on the command line, and only passed
to
gpgvia--pinentry-mode loopback --passphrase "$…"in memory. *.ascis in.gitignore. Don't commit key files.
Apache License 2.0 — see LICENSE.