GPG / PGP Encryption Cheat Sheet
GPG key generation, symmetric and asymmetric encryption, signing, key management, and revocation.
Security Tools
gpg
pgp
encryption
GPG (GnuPG) implements the OpenPGP standard for encryption and signing. It supports symmetric ciphers for files and asymmetric public/private key pairs for identity, confidentiality, and non-repudiation.
Generate and manage keys
bash
gpg --full-generate-key
gpg --list-keys
gpg --list-secret-keys
gpg --export --armor you@example.com > public.asc
gpg --export-secret-keys --armor you@example.com > private.asc
gpg --import public.asc
Table
| Command | Purpose |
|---|---|
--full-generate-key | Interactive key creation. |
--list-keys | List public keys. |
--list-secret-keys | List private keys. |
--export --armor | Export a public key as ASCII armor. |
--import | Import a key. |
Symmetric encryption
Symmetric encryption uses a single passphrase (no key pair).
bash
gpg --symmetric --cipher-algo AES256 secret.txt
gpg --decrypt secret.txt.gpg
Asymmetric encryption
Encrypt to a recipient's public key; only their private key can decrypt.
bash
gpg --encrypt --recipient you@example.com secret.txt
gpg --decrypt secret.txt.gpg
Signing and verification
bash
gpg --sign document.txt # embedded signature
gpg --clearsign document.txt # readable text + signature
gpg --detach-sign document.txt # separate .sig file
gpg --verify document.txt.sig document.txt
Table
| Command | Purpose |
|---|---|
--detach-sign | Produce a separate signature file. |
--verify | Check a signature. |
--clearsign | Signature readable in plain text. |
Revocation
bash
gpg --gen-revoke you@example.com > revoke.asc
gpg --import revoke.asc