GnuPG is the reference implementation of OpenPGP. It is what most of the other tools in this section are built on, and it is the one that will still be here when a graphical front end gets abandoned. The cost is that you have to type commands, and the benefit is that you can see exactly what is happening to your keys.
This is the version that works. Several older tutorials, including earlier drafts of this one, circulate commands that GnuPG simply rejects; the syntax below is current.
Installing
On Windows, install Gpg4win, which bundles GnuPG with Kleopatra and the command line tools. On macOS, the simplest route is brew install gnupg, or the GPG Suite installer from gpgtools.org. On Linux, GnuPG is almost always already installed; if not, use your package manager (sudo apt install gnupg on Debian and Ubuntu).
Check what you have with gpg --version. Anything from 2.2 onward is fine; 2.4 and later default to modern elliptic curve keys.
Generating a key
The interactive route is the one to use if you are unsure:
gpg --full-generate-keyIt asks for the key type, size, expiry, a name and an email. Choose ECC (sign and certify) with Curve 25519 if it is offered, otherwise RSA with 4096 bits. Set an expiry: two years is a reasonable default, and GnuPG will let you extend it later. For the identity, use the name you use on the market. The email can be a throwaway or left empty, but do not use a real address.
If you prefer one line, the correct form is:
gpg --quick-generate-key "Name <name@example.invalid>" ed25519 sign 2yThen add an encryption subkey, because a signing-only key cannot receive encrypted messages:
gpg --quick-add-key FINGERPRINT cv25519 encr 2yReplace FINGERPRINT with the 40-character fingerprint printed by the first command. Note the arguments: the algorithm comes before the usage, and the usage (sign, encr) is not optional. Commands that end in a bare - 0 are broken and will fail.
You will be asked for one passphrase. It protects the private key material, including the subkeys. There is no separate subkey password to set, despite what some guides say.
Make a revocation certificate
Do this immediately, before you need it:
gpg --output revoke.asc --gen-revoke FINGERPRINTStore revoke.asc somewhere offline and separate from the key. It is the only way to tell the world that a key is compromised, and it stops working if you lose the passphrase that protects it.
Backing up
gpg --export-secret-keys --armor --output private.asc FINGERPRINT
gpg --export --armor --output public.asc FINGERPRINTPut both on an encrypted volume, not in cloud storage. The secret export includes the private key, so treat the file as the key itself.
Importing someone else's key
gpg --import their-key.ascThen check the fingerprint before you trust it. GnuPG prints it on import; compare it character by character with the one published on the market or in a signed message. Setting trust is a local convenience, not a security control:
gpg --edit-key FINGERPRINT
> trust
> 4
> quitImporting with --import and no filename reads from standard input, which is useful for pasted keys but confusing if you expect a prompt.
Encrypting and decrypting
gpg --encrypt --recipient FINGERPRINT --armor --output message.asc message.txt
gpg --decrypt message.ascIf you omit --output, the armoured block is printed to the terminal and can be copied from there. Add --sign to sign as well as encrypt, which lets the recipient confirm the message came from your key.
Signing and verifying
gpg --clearsign --output signed.asc message.txt
gpg --verify signed.asc--clearsign keeps the text readable and adds a signature block, which is what markets expect for pinned announcements. Verification is --verify, not --decrypt; the latter works on signed-and-encrypted messages but reports the wrong thing on a clear-signed file.
A good signature means the file has not changed since it was signed and that it was signed by the key whose fingerprint is shown. It says nothing about whether that key belongs to who you think. That is what the fingerprint check is for.
The mistakes that matter
Generating a signing-only key and then wondering why nobody can encrypt to you. Skipping the revocation certificate. Backing up the public key and calling it a backup. Importing a key from a market page without checking the fingerprint. Setting an expiry and then ignoring the warnings, so the key quietly stops working. And pasting a private key into a chat window to move it between machines, which is the same as publishing it.
GnuPG is not friendly, but it is predictable. Once the key exists and is backed up, the rest is three commands and a habit.
