Skip to content

Instantly share code, notes, and snippets.

@andersondanilo
Created May 1, 2021 02:07
Show Gist options
  • Save andersondanilo/8b257c92593262692ee51f03cb2f5c08 to your computer and use it in GitHub Desktop.
Save andersondanilo/8b257c92593262692ee51f03cb2f5c08 to your computer and use it in GitHub Desktop.
export-gpg-key.sh
#!/usr/bin/bash
set -e
DEFAULT_KEY_ID=614C8C06DE5CB261AFC3EEE257F3E6589075F87C
SECRETS_KEY_ID=D1B5E88C16D8BD692D241317CAD86B57997C00AD
DEFAULT_PUB_FILE=anderson-default.pub.gpg
DEFAULT_SECRET_FILE=anderson-default-secret.asc.gpg
SECRETS_PUB_FILE=anderson-secrets.pub.gpg
SECRETS_SECRET_FILE=anderson-secrets-secret.asc.gpg
TRUST_FILE=trustdb-backup.txt.gpg
BACKUP_PASS=$(pass personal/linux/pgp-backup)
set +e
rm $DEFAULT_PUB_FILE
rm $DEFAULT_SECRET_FILE
rm $SECRETS_PUB_FILE
rm $SECRETS_SECRET_FILE
rm $TRUST_FILE
set -e
gpg --export -a $DEFAULT_KEY_ID | gpg -c --passphrase $BACKUP_PASS --batch -o $DEFAULT_PUB_FILE
gpg --export-secret-keys -a $DEFAULT_KEY_ID | gpg -c --passphrase $BACKUP_PASS --batch -o $DEFAULT_SECRET_FILE
gpg --export-ownertrust | gpg -c --passphrase $BACKUP_PASS --batch -o $TRUST_FILE
gpg --export -a $SECRETS_KEY_ID | gpg -c --passphrase $BACKUP_PASS --batch -o $SECRETS_PUB_FILE
gpg --export-secret-keys -a $SECRETS_KEY_ID | gpg -c --passphrase $BACKUP_PASS --batch -o $SECRETS_SECRET_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment