Skip to content

Instantly share code, notes, and snippets.

@j33ty
Last active July 29, 2019 08:06
Show Gist options
  • Save j33ty/6b62a3638525ec4a17059426a531cf0e to your computer and use it in GitHub Desktop.
Save j33ty/6b62a3638525ec4a17059426a531cf0e to your computer and use it in GitHub Desktop.
GPG Cheatsheet

GnuPG is a complete and free implementation of the OpenPGP standard.

Exporting keys

  • Export key to file: gpg -o key.gpg --export <KEY ID>
  • Export key in ASCII: gpg -o key.asc --export --armor <KEY ID>

Note: Omitting the -o|--output option will print the key to stdout.

Importing keys

  • gpg --import key.gpg
  • gpg --import key.asc

Managing your keyring

  • Generate new key: gpg --gen-key
  • Generate a new key with options dialog: gpg --full-gen-key
  • List public keys: gpg -k, gpg --list-keys
  • List secret keys: gpg -K, gpg --list-secret-keys

Trusting a key

gpg --edit-key <KEY ID>
# In the interactive prompt:
gpg> sign
gpg> save

Using paperkey to backup

  • Take the secret key in key.gpg and generate a text file to-be-printed.txt that contains the secret data: paperkey --secret-key my-secret-key.gpg --output to-be-printed.txt
  • Take the secret key data in my-key-text-file.txt and combine it with my-public-key.gpg to reconstruct my-secret-key.gpg: paperkey --pubring my-public-key.gpg --secrets my-key-text-file.txt --output my-secret-key.gpg

Refer: https://devhints.io/gnupg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment