# gpgx — gpg without the flag archaeology One verb per thing gpg is actually used for: lock, unlock, sign, verify, sum, keys. Every passphrase is typed in **this terminal** — no pinentry window ever opens. Quick card: **`gpgx-cheat`**. Raw command: **`gpgx -n …`**. ## The paste box Bare **`gpgx`** opens it. Paste anything, **ctrl-d** ends, **ctrl-c** aborts. There is no mode to choose — it reads what you pasted and does the only sensible thing: | What you paste | What happens | |---|---| | plain text | encrypted to your default key, armored — `gpgx -r KEY` picks someone else, `gpgx --sym` for passphrase-only | | `-----BEGIN PGP MESSAGE-----` | decrypted (asks for your passphrase) | | `-----BEGIN PGP SIGNED MESSAGE-----` | verified, then the text is printed | | `-----BEGIN PGP PUBLIC KEY BLOCK-----` | described — **imported: no** | (The private-key row is written without its leading `-----BEGIN` on purpose: the dotfiles secret scanner matches that exact header, and a cheat sheet describing it should not trip a check that exists to catch the real thing.) | `…PGP PRIVATE KEY BLOCK-----` | **refused.** Secret keys are never imported by accident | Output goes to **stdout always** (so it pipes) and to the **clipboard as well** when you are at a terminal — `pbcopy`, `wl-copy` or `xclip`, whichever exists. Redirect it (`gpgx > out.asc`) and the clipboard is skipped: a pipe wants bytes, not a side effect on the desktop session. - **`gpgx text -r alice@ex.com`** — encrypt to someone else instead of yourself. - **`gpgx text --sym`** — passphrase-only. They need no key, just the word. - **`gpgx text -s`** — sign it too, so they know it was you. - **`echo hi | gpgx`** — same thing from a pipe. This replaces the old habit `cat <`** — override for a whole shell. **`gpgx keys`** lists yours with **★** on the default. **`gpgx keys --public`** lists everyone else's. **`gpgx fp`** prints fingerprints grouped in fours, the way they are read aloud. ## Making and keeping keys - **`gpgx key new`** — guided: name, email, expiry, algorithm (**ed25519** modern, or **rsa4096** for old software). Uses `--quick-generate-key`, which builds the encryption subkey too — the interactive `--full-generate-key` dialogue makes you walk through that by hand. - **`gpgx key expire KEY 2y`** — push the expiry date out. Subkeys carry their own. - **`gpgx key passwd KEY`** — change the passphrase. This one hands off to gpg's own prompt, because gpg has no option to accept an old **and** a new passphrase on file descriptors. It still happens in this terminal; it just looks like gpg rather than gpgx. - **`gpgx key export KEY`** — public key, armored, to stdout. - **`gpgx key export --secret`** — the real thing. Warns first, writes mode **600**. - **`gpgx key import f.asc`** — read one in. - **`gpgx key revoke KEY`** — write the cancel-this-key certificate, mode 600. Store it **apart** from the key and never in the same backup. ### Backup — all three parts **`gpgx key backup`** writes a directory (mode 700, files 600) containing: | File | Why it is not optional | |---|---| | `secret-keys.asc` | the keys themselves | | `ownertrust.txt` | who you vouched for — a **separate database**. Lose it and every key you trusted drops back to "unknown". | | `openpgp-revocs.d/` | revocation certificates — without them you cannot announce a compromise you can no longer sign for | Secret keys alone are not a backup. Restore with `gpgx key import secret-keys.asc && gpg --import-ownertrust ownertrust.txt`. ## Trust — two different questions People conflate these constantly, and gpg's interface does nothing to help. 1. **Is this key really theirs?** → you check the **fingerprint** with them, out of band, then sign the key. 2. **Do I trust them to vouch for other people?** → that is **ownertrust**: `gpgx key trust`. | Level | Meaning | |---|---| | 1 unknown | no opinion. The default for everyone. | | 2 never | actively do not trust them to vouch for others | | 3 marginal | vouches somewhat — three marginals equal one full | | 4 full | you trust their signatures on other people's keys | | 5 ultimate | this is your own key. Nothing else belongs here. | Setting trust changes nothing about *them* — it changes which **other** keys gpg will accept as valid by way of them. It is local, private, never published, and the part everybody forgets to back up. ## Passphrases — when it asks, and why The rule: **unlocking a secret needs the word.** Nothing else does. | Command | Asks? | Why | |---|---|---| | `gpgx lock f` | no | a public key unlocks nothing | | `gpgx lock -s f` | yes | signing unlocks **your** key | | `gpgx lock --sym f` | yes, twice | you are choosing a new passphrase | | `gpgx unlock f.gpg` | yes | unlocking your secret key | | `gpgx sign`, `gpgx sum` | yes | same reason | | `gpgx verify`, `gpgx check` | no | verification is entirely public | | any command with `-n` | no | dry-run reports what *would* run | ### How it is typed Read from **`/dev/tty`** with `ECHO` off, one **`•`** painted per keystroke. Backspace and ctrl-u work. `getpass()` would do the reading but shows nothing at all — no cursor movement, no length, no sign the keyboard is connected, which is the single most common reason people think a tool "didn't ask". - **`--show-passphrase`** — echo it literally instead of masking. - **`--use-agent`** — hand the job back to gpg-agent instead. - **Never in argv**, so it never appears in `ps`. **Never in the environment**, so no child process inherits it. gpg receives it on a private file descriptor with `--pinentry-mode loopback`. That pairing is what stops the pinentry window from ever opening. ### When gpg-agent does the asking `key passwd`, `--use-agent` and `raw` cannot go by loopback, so gpg-agent raises its own pinentry for them. It still lands in **this terminal**: gpgx exports `PINENTRY_USER_DATA=gpgx-tty` (plus `GPG_TTY`), gpg forwards that to the agent, and the agent's `pinentry-program` is `~/.local/bin/pinentry-switch` — a dispatcher that runs **pinentry-tty** when it is `gpgx-tty` (or `tty`) and **pinentry-mac** otherwise. Plain `gpg`, `git commit -S` and GUI apps set nothing, so they get the window. The conf line is `pinentry-program /Users/daemon1/.local/bin/pinentry-switch` in `~/.gnupg/gpg-agent.conf` (absolute path — gpg-agent 2.2 does not expand `~`); `gpgconf --kill gpg-agent` reloads it. gpgx also starts the agent from a clean environment before exporting the marker, so a daemon it happens to launch never inherits `gpgx-tty` for everyone else. ## Suffixes | Suffix | Means | |---|---| | `.gpg` | binary encrypted (default) | | `.asc` | ascii-armored — encrypted, or a signature | | `.pgp` | binary, other tools' spelling | | `.sig` | detached binary signature | `gpgx unlock` and `gpgx verify` recognise all of them without a flag. ## Keyservers Default **`hkps://keys.openpgp.org`**, overridable with `--keyserver` or `GPGX_KEYSERVER`. - **`gpgx recv 0xDEADBEEF`** — fetch someone's key. - **`gpgx search alice@ex.com`** — look them up. - **`gpgx send`** — publish yours. **Public and permanent**; keyservers do not forget. keys.openpgp.org verifies the email address before publishing an identity, which is why it is the default rather than the old SKS pool — that pool is unmaintained and accepts poisoned keys. ## The escape hatches - **`gpgx -n `** — print the real gpg command and run nothing. The passphrase fd is shown as a placeholder, since the real number is an artifact of the process. - **`gpgx raw ARGS…`** — straight through to gpg, nothing translated. `gpgx raw --list-packets f.gpg` to see what is actually inside a file; `gpgx raw --edit-key KEY` for the full interactive dialogue. ## Why it does not just call `gpg` gpg's grammar is historical rather than logical. `--encrypt` and `--symmetric` are different **modes** rather than different flags. `--sign` means three unrelated things depending on which other option sits beside it. A detached signature and a clear signature are entirely different option names for what is conceptually one choice. And gpg-agent here runs `default-cache-ttl 0`, so every operation would otherwise raise a GUI window. gpgx picks one verb per intent, reads the passphrase itself, and spells the raw command out under `-n` — so nothing is hidden. The incantation is **taught**, not replaced, and `raw` is always there when the wrapper is in the way.