Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Small bash script to remove expired GPG keys from the local machine.
expired_keys="$(gpg --list-keys --fixed-list-mode --with-colons | grep "^pub:[re]:" | cut -f5 -d":")"
for key in $expired_keys; do
gpg --list-keys "$key"
gpg --no-greeting --delete-secret-key "$key" # will ask for confirmation
gpg --no-greeting --delete-key "$key" # will ask for confirmation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.