Simple GPG cheat sheet

Create a new gpg key

gpg --full-gen-key

This will create a .gnupg folder in you home directory.

$ tree ~/.gnupg

├── crls.d
│   └── DIR.txt
├── dirmngr.conf
├── openpgp-revocs.d
│   └── XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.rev
├── private-keys-v1.d
│   ├── XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.key
│   └── XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.key
├── pubring.kbx
├── random_seed
└── trustdb.gpg

Show keys

gpg --list-keys

Encrypt file

gpg --encrypt --recipient <YOUR.ID@WHATEVER.COM> <THE_UNENCRYPTED_FILE>

Decrypt file

gpg --decrypt <THE_ENCRYPTED_FILE>.gpg

Exporting public key

gpg --output public.pgp --armor --export <YOUR.ID@WHATEVER.COM>

Exporting priv key

gpg --output private.pgp --armor --export-secret-key <YOUR.ID@WHATEVER.COM>

Import key

gpg --import pubkey.asc
gpg --import privkey.asc

Edit key

gpg --edit-key <YOUR.ID@WHATEVER.COM>