Skip to content

Instantly share code, notes, and snippets.

@danylkaaa
Created August 8, 2021 11:43
Show Gist options
  • Save danylkaaa/b7369235a522e3b3ff110e373a28c9cc to your computer and use it in GitHub Desktop.
Save danylkaaa/b7369235a522e3b3ff110e373a28c9cc to your computer and use it in GitHub Desktop.
Backup GPG keys
> gpg --list-secret-keys

# Command output example:
# Users/risan/.gnupg/pubring.kbx
# -------------------------------
# sec   rsa4096 2017-12-12 [SC]
#      D020LB50C994521EB6E9EEE932B805973FE94CAC
# uid           [ultimate] <NAME> <EMAIL>
# ssb   rsa4096 2017-12-12 [E]

> gpg --export-secret-keys --armor "<EMAIL>" > private.key
> gpg --export-ownertrust > /path/to/trustdb-backup.txt
gpg —-import /path/to/secret-key-backup.asc
gpg --import-ownertrust < /path/to/trustdb-backup.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment