// Encrypt. Sign. Verify.
ENCRYPTION IS LIBERTY.
In a world of surveillance and data breaches, encryption is your last line of defense. GPG (GNU Privacy Guard) gives you military-grade encryption for your files, emails, and communications.
YOUR KEYS, YOUR DATA.
With GPG, you control your encryption. No corporations, no backdoors. Only those with your private key can read your messages. That's real security.
Click a lesson to begin
What is GPG? Encryption basics and why it matters.
BeginnerCreate your first key pair. Master key and subkeys.
BeginnerList, export, import, and revoke keys.
BeginnerEncrypt files for yourself or others using public keys.
BeginnerDecrypt files using your private key.
BeginnerSign files to prove authenticity and integrity.
IntermediateVerify signatures from others. Trust models.
IntermediatePublish your public key. Find others' keys.
IntermediateSet up email encryption with GPG. Thunderbird, mutt.
IntermediateSecure backup of keys. Paper backups. Revocation certificates.
AdvancedManage subkeys. Set expiration dates. Key rotation.
AdvancedSmartcards, YubiKey, Tor, and best practices.
AdvancedGPG (GNU Privacy Guard) is a free implementation of the OpenPGP standard. It's used for encrypting data and communications, signing messages, and verifying signatures.
GPG uses asymmetric encryption:
1. What does GPG stand for?
# Debian/Ubuntu sudo apt install gnupg # macOS brew install gnupg # Check version gpg --version
# Interactive key generation gpg --full-generate-key # Or use batch mode for scripting gpg --batch --gen-key <Key Types
- RSA: Most compatible, up to 4096 bits
- ECC: Smaller keys, modern, gaining support
Quiz
1. What should you never share?
Show Answers
- Your private key
# List secret keys gpg --list-secret-keys # List all keys gpg --list-keys # List keys with fingerprints gpg --fingerprint
# Export public key to file gpg --armor --export your@email.com > public-key.asc # Export secret key (backup!) gpg --armor --export-secret-keys your@email.com > secret-key-backup.asc
# Import a public key gpg --import keyfile.asc # Import from keyserver gpg --keyserver keyserver.ubuntu.com --search-keys user@email.com
# Delete public key gpg --delete-keys your@email.com # Delete secret key gpg --delete-secret-keys your@email.com
1. What command lists your secret keys?
# Encrypt a file (defaults to .gpg) gpg --encrypt myfile.txt # Encrypt with specific recipient gpg --encrypt --recipient your@email.com myfile.txt # Encrypt symmetrically (password only) gpg --symmetric myfile.txt # ASCII armored output (for email) gpg --armor --encrypt --recipient your@email.com myfile.txt
gpg --encrypt \
--recipient alice@example.com \
--recipient bob@example.com \
myfile.txt
1. Which flag specifies the recipient?
# Decrypt to stdout (view content) gpg --decrypt secret.txt.gpg # Decrypt and save to file gpg --decrypt --output original.txt secret.txt.gpg # Decrypt (gpg automatically finds your private key)
# You'll be prompted for the passphrase gpg --decrypt secret.txt.gpg
# Decrypt all files in a directory
for file in *.gpg; do
gpg --decrypt "$file" --output "${file%.gpg}"
done
1. What command decrypts a file?
Signing proves that:
# Create detached signature gpg --sign myfile.txt # Detached signature (separate .sig file) gpg --armor --detach-sign myfile.txt # Clear signature (readable + signature) gpg --clearsign message.txt
# Sign (can be read, proves it's from you) gpg --local-user your@email.com --sign document.pdf
1. What does signing prove?
# Verify a signed file gpg --verify signed-file.gpg # Verify and extract gpg --decrypt signed-file.txt.gpg # Verify detached signature gpg --verify file.sig file
# Edit key trust gpg --edit-key user@email.com trust 5 # Ultimate quit
1. What command verifies a signature?
Key servers store and share public keys, making it easy for others to find your key and encrypt messages for you.
# Upload to keyserver gpg --keyserver keys.openpgp.org --send-keys your@email.com # Search for a key gpg --keyserver keys.openpgp.org --search-keys user@email.com # Import found key gpg --keyserver keys.openpgp.org --recv-keys KEYID
1. What should you never upload to key servers?
Email is inherently insecure. GPG encrypts the content so only the recipient can read it.
# Install GPGTools brew install --cask gpgtools # This adds GPG support to Mail.app
# Encrypt email body echo "Secret message" | gpg --armor --encrypt --recipient recipient@email.com # Use mutt with GPG # Add to ~/.muttrc: set pgp_use_gpg = yes
1. What does email GPG encryption protect?
If you lose your private key, you can never decrypt your files. If someone gains your private key, they can impersonate you.
# Export public key (safe to share) gpg --armor --export your@email.com > public-key.asc # Export secret key (KEEP SECURE!) gpg --armor --export-secret-keys your@email.com > secret-key.asc # Export subkeys only gpg --armor --export-secret-subkeys your@email.com > subkeys.asc
# Print paper backup gpg --armor --export-secret-keys your@email.com | paperkey | a2ps | ps2pdf - > key.pdf # Or use QR codes # apt install qrencode gpg --armor --export your@email.com | qrencode -o key.png
# Generate revocation certificate NOW gpg --output revocation-certificate.asc --gen-revoke your@email.com # Store this safely. Use it if key is compromised.
1. When should you create a revocation certificate?
# Edit your key gpg --edit-key your@email.com addkey # Choose RSA (4096) # Set expiration # Save save
# Edit key gpg --edit-key your@email.com # List keys list # Select subkey key 1 # Set expiration expire # Save save
Best practice: Create new encryption subkeys yearly. Keep your master key safe.
1. What is the benefit of subkeys?
Store your private key on a smartcard or YubiKey for maximum security.
# Install yubikey-manager brew install yubikey-manager # Configure GPG on YubiKey ykman openpgp keys import
# Use keyserver through Tor gpg --keyserver hkps://keys.openpgp.org --search-keys user@email # Configure in ~/.gnupg/gpg.conf keyserver hkps://keys.openpgp.org
You've completed the GPG Mastery guide. You now understand:
GPG is the gold standard for encryption. It's used by journalists, activists, developers, and anyone who values privacy.
Unlike proprietary encryption, GPG is open source and audited. Your keys are yours—there's no company that can hand them over to authorities.
Encrypt. Sign. Verify. Own your data.