gpg, one key per page
Twenty-eight lessons on gpg, one key or one signature per page: what GnuPG is and what public-key cryptography means; the keypair, a private key that never leaves and a public key you hand out; the fingerprint as the identity; generating a first key; where keys live on disk; symmetric mode against encrypting for someone else; the armor; signing a file, detached signatures, clearsign and what signing proves; the web of trust, trust levels, key signing parties and TOFU; export and import, key servers, the revocation certificate, expiry and subkeys; verifying a download's signature end to end; encrypting email, inline versus PGP/MIME; the honest limits and the quantum question; a first end-to-end; when verify fails; and teaching a friend to verify one signature.
One key, one page, one real capture. That's the rhythm.
gpg, one key per page
Twenty-eight lessons on gpg, one key or one signature per page: what GnuPG is and what public-key cryptography means; the keypair, a private key that never leaves and a public key you hand out; the fingerprint as the identity; generating a first key; where keys live on disk; symmetric mode against encrypting for someone else; the armor; signing a file, detached signatures, clearsign and what signing proves; the web of trust, trust levels, key signing parties and TOFU; export and import, key servers, the revocation certificate, expiry and subkeys; verifying a download's signature end to end; encrypting email, inline versus PGP/MIME; the honest limits and the quantum question; a first end-to-end; when verify fails; and teaching a friend to verify one signature.
Set in Space Grotesk, Inter and JetBrains Mono (SIL Open Font License).
Every fact in this book is as the official source states it, fetched and read during this build: the GnuPG manual pages from gnupg.org (the definition of truth, converted from the official HTML: Invoking GPG, Trust Values, the Glossary, the table of contents), and the Wikipedia articles GNU Privacy Guard, Pretty Good Privacy, OpenPGP, Public-key cryptography, Web of trust, Key signing party, Digital signature, Email encryption, Birthday attack and RSA cryptosystem, the last under its real title (the parenthesized URL caches as a redirect stub). The gnupg.org FAQ URL 404s and is not used. No facts are sourced from Reddit, Stack Overflow or vendor blogs. Every command and output pair was run on this machine (gpg (GnuPG) 2.4.4 at /usr/bin/gpg, Ubuntu 24.04) in throwaway scratch directories, GNUPGHOME at throwaway homes, throwaway --quick-generate-key test identities only, never a real key; keys are fresh per build, so fingerprints differ. Honest deviations: gpg 2.4.4 has no --with-subkeys option, and --gen-revoke refuses batch mode and prompts on a tty, so it ran under a pty. An independent guide, not affiliated with or endorsed by the Free Software Foundation, g10 Code GmbH or the Wikimedia Foundation.
Your purchase is for personal use only. You do not have redistribution rights: please do not share, resell, or republish this book or its pages.
© 2026 Steve Hodgkiss. All rights reserved. Personal use only; no redistribution rights.
Edition 1.0 · stevehodgkiss.net
Contents
Per the Wikipedia Public-key cryptography article, in an asymmetric key encryption scheme anyone can encrypt messages using a public key, but only the holder of the paired private key can decrypt such a message; the security of the system depends on the secrecy of the private key, which must not become known to any other; and in the standard signing picture Alice signs a message with her private key while Bob, using Alice's public key, can verify that Alice sent the message and that it has not been modified. This machine's captures: gpg --list-secret-keys printed sec ed25519 ... [SC] with ssb cv25519 [E], and gpg --list-keys printed the matching pub and sub lines.
The keypair
Two keys, one identity. The public key you hand out: anyone may use it to encrypt to you, and anyone may use it to verify your signatures. The private key that never leaves: only it decrypts, only it signs.
The law from the article is blunt: security depends on the secrecy of the private key, which must not become known to any other.
Our listing shows both halves: sec ed25519 with the secret, pub its public twin, one fingerprint between them.
List your secret keys and your public keys; confirm every sec line has a pub twin.
Per the Wikipedia OpenPGP article, PGP uses a hybrid cryptosystem by combining symmetric-key encryption and public-key encryption: the message is encrypted using a symmetric algorithm under a one-time session key, and the session key is protected by encrypting it with the receiver's public key. Per the GnuPG manual's Invoking GPG chapter, gpg provides digital encryption and signing services using the OpenPGP standard. This machine's captures: gpg --symmetric note.txt with a passphrase produced note.sym.gpg; decrypting it printed the original two lines and reported gpg: AES256.CFB encrypted data and gpg: encrypted with 1 passphrase.
Symmetric mode
gpg --symmetric note.txt is the keypair-free corner: one passphrase both locks and unlocks. Ours answered AES256.CFB encrypted data, encrypted with 1 passphrase, and gave the two lines back.
Even here the hybrid design from the OpenPGP article shows: a one-time session key encrypts the data; the passphrase merely guards that key. Public-key mode swaps the guard for a public key.
Simple to send a friend, one shared secret to keep. Fine for a file on a disk; wrong tool for correspondence.
Encrypt one file with --symmetric, decrypt it back, and read the two status lines.
Per the Wikipedia Digital signature article, a digital signature is a mathematical scheme for verifying the authenticity of digital messages or documents, and a valid digital signature on a message gives any recipient confidence that the message came from a sender known to the recipient. Per the Wikipedia Public-key cryptography article, Alice signs a message with her private key and Bob, using Alice's public key, can verify that Alice sent the message and that the message has not been modified. This machine's captures: gpg --sign note.txt produced note.txt.gpg; gpg --verify note.txt.gpg reported gpg: Good signature from "Test One " [ultimate]; decrypting wrote the original two lines back.
Sign a file
gpg --sign note.txt packs data and signature into one compressed file, note.txt.gpg. One object to move, one command to check.
The verdict lands in the verify: Good signature from "Test One
The claim is the article's: the signature gives any recipient confidence the message came from a sender known to the recipient. Not secret; proven.
Sign one file with --sign, verify it, then decrypt it and diff against the original.
Per the GnuPG manual's Trust Values page, trust values indicate ownertrust and validity of keys and user IDs and are displayed with letters or strings: unknown, no ownertrust assigned or not yet calculated; e expired, trust calculation failed probably due to an expired key; q undefined, not enough information; n never, never trust this key; m marginal, marginally trusted; f full, fully trusted; u ultimate, ultimately trusted; r revoked, for validity only. This machine's captures: the key listings showed uid [ultimate]; the edit-key trust menu offered 1 I don't know, 2 I do NOT trust, 3 I trust marginally, 4 I trust fully, 5 I trust ultimately; gpg reported marginals needed: 3 completes needed: 1 trust model: pgp; and --export-ownertrust printed the fingerprint lines ending :6: and, after the change, :5:.
Trust levels
The manual's ladder, bottom to top: unknown, never, marginal, full, ultimate. The last is yours alone; every key you make starts there.
The engine's arithmetic, captured: marginals needed: 3, completes needed: 1, trust model: pgp. Three marginal friends or one full one vouch, and a key becomes valid to you.
Ownertrust exports as digits: ours read :6: ultimate, then :5: after we demoted Test Two to full. Trust you can list is trust you can audit.
Open --edit-key, walk the trust menu, then export your ownertrust and read the digits.
Per the Wikipedia OpenPGP article, OpenPGP versions have always included a way to revoke public key certificates, and a lost or compromised private key will require this if communication security is to be retained; this is more or less equivalent to the certificate revocation lists of centralized PKI schemes. This machine's captures: at key generation gpg itself printed revocation certificate stored as openpgp-revocs.d/AD42A7D70194E10BA7361926B9FA173A7D8620F6.rev; gpg --gen-revoke offered reasons 0 No reason specified, 1 Key has been compromised, 2 Key is superseded, 3 Key is no longer used, suggested Probably you want to select 1 here, and warned that if Mallory gets access to this certificate he can use it to make your key unusable; the armored output carried the line Comment: This is a revocation certificate.
The revocation cert
A lost or compromised key must be revoked, says the article, or your security is gone with it. GnuPG agrees loudly: at generation it already stored a certificate, openpgp-revocs.d/...rev, before you asked.
gpg --gen-revoke makes another. The reasons are numbered, 0 to 3; gpg itself hints probably you want to select 1 here, compromised.
Handle it like a loaded brake: if Mallory gets it, your key is unusable. Print it, hide it, away from the key it kills.
Generate a revocation certificate for a throwaway key; store it outside the GNUPGHOME.
Per the GnuPG manual glossary, a Keygrip is a 20 byte hash value used to identify a certain key without referencing a concrete protocol, used internally to access a private key, and shown as a 40 character hexadecimal string. Per this book's plan, a gpg key is really a primary certificate plus subkeys, each with its own usage flags. This machine's captures: the fresh key listed pub ed25519 ... [SC] with sub cv25519 [E], one pair of jobs; gpg --quick-add-key FPR rsa2048 sign never added sub rsa2048 [S]; the listing with keygrips showed each key's separate Keygrip line, three secrets in private-keys-v1.d.
Subkeys
One key, several hands. The primary, ours ed25519 [SC], certifies the identity and signs; a sub, cv25519 [E], does the encryption. Flags name each job.
gpg --quick-add-key FPR rsa2048 sign never gave ours a second signing hand: sub rsa2048 [S]. Each part carries its own Keygrip, the manual's protocol-free name, its own file in private-keys-v1.d.
Why bother: keep the certifying key offline and move a replaceable signing subkey to your laptop. A lost subkey is an inconvenience; a lost primary is an identity.
Add one subkey to a throwaway key; list keygrips and count the files in private-keys-v1.d.
Per this book's plan, the one command worth teaching is gpg --verify file.sig file, because a friend who can verify one signature can be told the key came from you by a second channel. Per the Wikipedia GNU Privacy Guard article, keys must always be exchanged carefully to prevent identity spoofing. This machine's capture: the closing run, gpg --verify note.txt.sig note.txt on the untampered file, answered gpg: Good signature from "Test One " [ultimate] and exited 0, where the tampered file had answered BAD signature and exited 1.
Teaching a friend
Teach one command, not a lecture: gpg --verify note.txt.sig note.txt. Our close-out run answered Good signature ... [ultimate] and exited 0; the tampered twin had answered BAD and exited 1.
Then teach the three lines to read: whose signature, what verdict, which fingerprint. Exit codes carry it into scripts.
Last move, the human one: hand them the key over a second channel and make them compare the fingerprint themselves. That is the whole web of trust, two people at a time.
Sit with one friend this week; have them verify one signature and say the verdict aloud.