2014-05-27 08:49:33 +10:00
|
|
|
# gpg
|
|
|
|
|
2025-03-19 12:23:48 +00:00
|
|
|
> GNU Privacy Guard, an OpenPGP encryption and signing tool.
|
|
|
|
> More information: <https://gnupg.org/documentation/manuals/gnupg/Invoking-GPG.html>.
|
2014-05-27 08:49:33 +10:00
|
|
|
|
2021-07-06 04:19:59 +01:00
|
|
|
- Create a GPG public and private key interactively:
|
|
|
|
|
|
|
|
`gpg --full-generate-key`
|
|
|
|
|
2025-03-19 12:23:48 +00:00
|
|
|
- List all keys from the public keyring:
|
|
|
|
|
|
|
|
`gpg {{[-k|--list-keys]}}`
|
|
|
|
|
2021-01-31 14:05:18 -03:00
|
|
|
- Sign `doc.txt` without encryption (writes output to `doc.txt.asc`):
|
2014-05-27 08:49:33 +10:00
|
|
|
|
|
|
|
`gpg --clearsign {{doc.txt}}`
|
|
|
|
|
2025-03-19 12:23:48 +00:00
|
|
|
- Encrypt and sign `doc.txt` for `alice@example.com` and `bob@example.com` (output to `doc.txt.gpg`):
|
2014-05-27 08:49:33 +10:00
|
|
|
|
2025-03-19 12:23:48 +00:00
|
|
|
`gpg {{[-es|--encrypt --sign]}} {{[-r|--recipient]}} {{alice@example.com}} {{[-r|--recipient]}} {{bob@example.com}} {{doc.txt}}`
|
2014-05-27 08:49:33 +10:00
|
|
|
|
2021-01-31 14:05:18 -03:00
|
|
|
- Encrypt `doc.txt` with only a passphrase (output to `doc.txt.gpg`):
|
2014-05-27 08:49:33 +10:00
|
|
|
|
2025-03-19 12:23:48 +00:00
|
|
|
`gpg {{[-c|--symmetric]}} {{doc.txt}}`
|
2014-05-27 08:49:33 +10:00
|
|
|
|
2022-12-04 08:53:34 +01:00
|
|
|
- Decrypt `doc.txt.gpg` (output to `stdout`):
|
2014-05-27 08:49:33 +10:00
|
|
|
|
2025-03-19 12:23:48 +00:00
|
|
|
`gpg {{[-d|--decrypt]}} {{doc.txt.gpg}}`
|
2014-08-13 20:48:25 +02:00
|
|
|
|
2016-01-07 18:31:27 +01:00
|
|
|
- Import a public key:
|
2014-08-13 20:48:25 +02:00
|
|
|
|
2015-10-22 15:31:52 +08:00
|
|
|
`gpg --import {{public.gpg}}`
|
2016-06-20 23:58:28 +01:00
|
|
|
|
2025-03-19 12:23:48 +00:00
|
|
|
- Export the public/private key for `alice@example.com` (output to `stdout`):
|
2016-06-20 23:58:28 +01:00
|
|
|
|
2025-03-19 12:23:48 +00:00
|
|
|
`gpg {{--export|--export-secret-keys}} {{[-a|--armor]}} {{alice@example.com}}`
|