gpg Command Examples
GNU Privacy Guard, an OpenPGP encryption and signing tool. More information: https://gnupg.org/documentation/manuals/gnupg/Invoking-GPG.html.
- Create a GPG public and private key interactively:
gpg {{[--full-gen-key|--full-generate-key]}}
- List all keys from the public keyring:
gpg {{[-k|--list-keys]}}
- Sign
doc.txt
without encryption (writes output todoc.txt.asc
):
gpg --clearsign {{doc.txt}}
- Encrypt and sign
doc.txt
for[email protected]
and[email protected]
(output todoc.txt.gpg
):
gpg {{[-es|--encrypt --sign]}} {{[-r|--recipient]}} {{[email protected]}} {{[-r|--recipient]}} {{[email protected]}} {{doc.txt}}
- Encrypt
doc.txt
with only a passphrase (output todoc.txt.gpg
):
gpg {{[-c|--symmetric]}} {{doc.txt}}
- Decrypt
doc.txt.gpg
(output tostdout
):
gpg {{[-d|--decrypt]}} {{doc.txt.gpg}}
- Import a public key:
gpg --import {{public.gpg}}
- Export the public/private key for
[email protected]
(output tostdout
):
gpg {{--export|--export-secret-keys}} {{[-a|--armor]}} {{[email protected]}}