GnuPG Cheatsheet
GnuPG Cheatsheet
GnuPG Cheatsheet
Basics
Exporting keys
Note: Omitting the -o|--output option will print the key to stdout.
Importing keys
1/5
gpg --gen-key
# or, generate a new key with dialogs for all options
gpg --full-gen-key
gpg -k
gpg --list-keys
gpg -K
gpg --list-secret-keys
Using a keyserver
gpg --refresh-keys
Trusting a key
NOTE: You can use the owner’s email or name (or part thereof) instead of the key ID for
--edit-key
Encrypting
This will produce an encrypted file, secret.txt.gpg, that can only be decrypted by the
recipient:
2/5
gpg -e -o secret.txt.gpg -r <RECIPIENT> secret.txt
For <RECIPIENT> you can use their key ID, their email, or their name (or part thereof).
Symmetric encryption
Encrypt file using a shared key. You will be prompted for a passphrase.
Decrypting
Decrypting a file
If the file is encrypted via symmetric encryption, you will be prompted for the passphrase.
Signing
gpg -s -o secret.txt.gpg \
-r <RECIPIENT> secret.txt
Verifying a signature
3/5
gpg -d signed-file.txt.gpg
Miscellaneous
Components
List all components:
gpgconf --list-components
Kill a component:
gpg -k --with-colons
Field # Description
1 Record type
2 Validity
5 Key ID
6 Creation date
7 Expiry date
9 Ownertrust
10 User ID
11 Signature class
12 Key capabilities
13 Issuer fingerprint
4/5
14 Flag field
15 S/N of token
16 Hash algorithm
17 Curve name
18 Compliance flags
20 Origin
5/5