9 [GnuPG](https://gnupg.org/) is a complete and free implementation of the OpenPGP standard.
18 gpg -o key.gpg --export <KEY ID>
21 __Export key in ASCII:__
24 gpg -o key.asc --armor --export <KEY ID>
27 __Note:__ Omitting the `-o|--output` option will print the key to `stdout`.
36 Only merge updates for keys already in key-ring:
39 gpg --import key.asc --merge-options merge-only
42 ### Managing your keyring
49 # or, generate a new key with dialogs for all options
64 gpg --list-secret-keys
70 Import keys from keyserver:
74 gpg --receive-keys <KEY IDS>
77 Upload keys to keyserver:
80 gpg --send-keys <KEY IDS>
83 Request updates from keyserver for keys already in your keyring:
89 Search keys from keyserver:
92 gpg --search-keys "<SEARCH STRING>"
95 Override keyserver from `~/.gnupg/gpg.conf`
98 gpg --keyserver <URL> ...
104 gpg --edit-key <KEY ID>
105 # In the interactive prompt:
110 __NOTE:__ You can use the owner's email or name (or part thereof) instead of the key ID for `--edit-key`
117 ### Public key encryption
118 This will produce an encrypted file, `secret.txt.gpg`, that can only be decrypted by the recipient:
121 gpg -e -o secret.txt.gpg -r <RECIPIENT> secret.txt
124 For `<RECIPIENT>` you can use their key ID, their email, or their name (or part thereof).
127 gpg -e -r <KEY ID> ...
129 gpg -e -r "bezalelhermoso@gmail.com" ...
132 Specifying multiple recipients
135 gpg -e -r <RECIPIENT> -r <ANOTHER RECIPIENT> ... secret.txt
138 __NOTE__: Omitting `-o|--output` will produce an encrypted file named `<ORIGINAL FILENAME>.gpg` by default.
140 ### Symmetric encryption
142 Encrypt file using a shared key. You will be prompted for a passphrase.
145 gpg --symmetric secret.txt
154 ### Decrypting a file
157 gpg -d -o secret.txt secret.txt.gpg
160 If the file is encrypted via symmetric encryption, you will be prompted for the passphrase.
162 __NOTE__: Omitting `-o|--output` will print the unencrypted contents to `stdout`
171 gpg -o signed-file.txt.gpg -s file.txt
174 This can be used during encryption to also sign encrypted files:
177 gpg -s -o secret.txt.gpg \
178 -r <RECIPIENT> secret.txt
181 ### Verifying a signature
184 gpg --verify file.txt.gpg
187 ### Viewing content of signed file
190 gpg -d signed-file.txt.gpg
203 gpgconf --list-components
209 gpgconf --kill <COMPONENT> # i.e. gpgconf --kill dirmngr
217 ### Parsing keyring data
219 Use `--with-colons` to produce an output that can easily be parsed i.e. with `awk`, `grep`. Fields are colon-separated.
225 Field Quick Reference:
227 | Field # | Description |
230 | 3 | Key length in bits |
231 | 4 | Public key algorithm |
233 | 6 | Creation date |
235 | 8 | Certificate S/N, UID hash, trust signature info |
238 | 11 | Signature class |
239 | 12 | Key capabilities |
240 | 13 | Issuer fingerprint |
242 | 15 | S/N of token |
243 | 16 | Hash algorithm |
245 | 18 | Compliance flags |
246 | 19 | Last update timestamp |
249 See [GnuPG Details](https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob_plain;f=doc/DETAILS) for more details.