What is GPG?
GNU Privacy Guard. It uses public-key cryptography for file encryption, digital signatures, and email encryption.
Generating Keys
Bash
gpg --full-generate-key
# RSA 4096 or Ed25519 , 2y
gpg --list-keys
gpg --list-secret-keys --keyid-format LONGFile Encryption (Public-Key)
Bash
gpg --encrypt --recipient "admin@example.com" secret.txt
# → secret.txt.gpg
gpg --decrypt secret.txt.gpg > secret.txt
gpg --armor --encrypt --recipient "admin@example.com" secret.txt
# → secret.txt.ascSymmetric Encryption (Password-Based)
Bash
gpg --symmetric --cipher-algo AES256 backup.tar.gz
gpg --decrypt backup.tar.gz.gpg > backup.tar.gzDigital Signatures
Bash
gpg --detach-sign release.tar.gz
# → release.tar.gz.sig
gpg --verify release.tar.gz.sig release.tar.gz
gpg --sign --encrypt --recipient "admin@example.com" file.txtExporting / Importing Keys
Bash
gpg --armor --export "admin@example.com" > public.key
gpg --armor --export-secret-keys "admin@example.com" > private.key
gpg --import public.key
gpg --import private.keyEditorial note
AI tools may assist drafting. Check the evidence in each guide for whether commands were run and which environment was used. Confirm the current docs for your version before applying instructions, and email us about errors. email us
Topic-related official docs (auto-linked · not per-claim sources)OWASP documentation ↗
Questions & answers
Ask a question about this guide. We'll review and reply.