2019-08-02 02:15:39 +00:00
|
|
|
# GPG Cheat Sheet
|
|
|
|
|
|
|
|
## Create a key
|
2020-05-19 03:02:34 +00:00
|
|
|
* `gpg --expert --full-generate-key`
|
|
|
|
* RSA (set your own capabilities)
|
|
|
|
* Set to Certify only
|
|
|
|
* 4096
|
|
|
|
* 2020-01-01
|
|
|
|
* `gpg --expert --edit-key <userid>`
|
|
|
|
* `addkey` (Create 3, one for sign, encrypt, authenticate)
|
|
|
|
* `addphoto` *(240x288)*
|
|
|
|
* `save`
|
|
|
|
* `quit`
|
|
|
|
* `gpg -a --output revoke.asc --gen-revoke '<fingerprint>'`
|
2019-06-28 02:39:56 +00:00
|
|
|
|
2019-08-02 02:15:39 +00:00
|
|
|
## Backup key
|
2020-05-19 03:02:34 +00:00
|
|
|
* `gpg -a --export-secret-key <userid> > secret_key.gpg`
|
2019-06-28 02:39:56 +00:00
|
|
|
* `gpg -a --export-secret-subkeys <userid> > secret_subkeys.gpg`
|
|
|
|
* `gpg --delete-secret-keys <userid>`
|
|
|
|
* `gpg --import secret_subkeys.gpg`
|
|
|
|
* `gpg --list-secret-keys`
|
2020-05-19 03:02:34 +00:00
|
|
|
* `gpg --edit-key <KEYID>` *(type `trust` and press `5`)*
|
2019-06-28 02:39:56 +00:00
|
|
|
|
2019-08-02 02:15:39 +00:00
|
|
|
## Import/Export public key
|
2019-06-28 02:39:56 +00:00
|
|
|
* `gpg --import public.key`
|
|
|
|
* `gpg --output public.key --armor --export <userid>`
|
|
|
|
* `gpg --export-secret-keys --armor <userid> > privkey.asc`
|
|
|
|
|
2019-08-02 02:15:39 +00:00
|
|
|
## List (secret) keys
|
2019-06-28 02:39:56 +00:00
|
|
|
* `gpg --list-keys`
|
|
|
|
* `gpg --list-secret-keys`
|
|
|
|
|
2019-08-02 02:15:39 +00:00
|
|
|
## Encrypt/Decrypt
|
2019-06-28 02:39:56 +00:00
|
|
|
* `gpg --recipient user-id --encrypt doc`
|
|
|
|
* `gpg --output doc --decrypt doc.gpg`
|
|
|
|
|
|
|
|
or...
|
|
|
|
|
|
|
|
* `gpg -c --s2k-cipher-algo AES256 --s2k-digest-algo SHA512 --s2k-count 65536 doc`
|
|
|
|
* `gpg --output doc --decrypt doc.gpg`
|
|
|
|
|
2019-08-02 02:15:39 +00:00
|
|
|
## Signing
|
2019-06-28 02:39:56 +00:00
|
|
|
* `gpg --output doc.sig --sign doc`
|
|
|
|
* `gpg --output doc.sig --clearsign doc`
|
|
|
|
* `gpg --output doc.sig --detach-sig doc`
|
|
|
|
|
2019-08-02 02:15:39 +00:00
|
|
|
## Verify
|
2020-05-19 03:02:34 +00:00
|
|
|
* `gpg --verify example.sig`
|
|
|
|
* `gpg --verify example.sig /path/to/example.iso`
|
2019-06-28 02:39:56 +00:00
|
|
|
* `gpg --with-fingerprint <keyfile>`
|
|
|
|
|
2019-08-02 02:15:39 +00:00
|
|
|
## Send keys
|
2020-05-19 03:02:34 +00:00
|
|
|
* `gpg --keyserver <keyserver> --send-keys <user-id>`
|
|
|
|
* `gpg --recv-key '<fingerprint> && gpg --fingerprint '<fingerprint>'`
|
|
|
|
* `gpg --search-keys '<userid>'`
|
2019-06-28 02:39:56 +00:00
|
|
|
|
2019-08-02 02:15:39 +00:00
|
|
|
## Sign key
|
2019-06-28 02:39:56 +00:00
|
|
|
* `gpg --lsign-key '<fingerprint>'`
|
|
|
|
|
|
|
|
or...
|
|
|
|
|
|
|
|
* `gpg --sign-key '<fingerprint>'`
|