rtfd/in/public/security/gpg/index.rst

289 lines
3.5 KiB
ReStructuredText
Raw Normal View History

2017-12-02 22:02:37 +00:00
###
GPG
###
2017-12-05 21:32:10 +00:00
TODO
====
* setpref, or elsehow at key generation
* ! suffix to exclude subkeys
* trust
* sign
* delete
* ssh authentication ???
Configure
=========
2019-05-03 12:03:26 +00:00
If up:
.. code:: shell
killall gpg-agent
killall dirmngr
2017-12-05 21:32:10 +00:00
wipe if needed
--------------
.. code:: shell
rm --force --recursive ~/.gnupg
mkdir -m 700 ~/.gnupg
check available algorithms
--------------------------
.. code:: shell
gpg --version
avoid default use of SHA256
---------------------------
* gpg.conf
::
2019-05-03 15:44:02 +00:00
default-preference-list SHA512 AES256 BZIP2
2017-12-05 21:32:10 +00:00
2019-05-03 15:44:02 +00:00
cert-digest-algo SHA512
cipher-algo AES256
compress-algo BZIP2
digest-algo SHA512
2017-12-05 21:32:10 +00:00
2019-05-03 15:44:02 +00:00
personal-cipher-preferences AES256
personal-digest-preferences SHA512
personal-compress-preferences BZIP2
2019-05-03 13:24:36 +00:00
with-keygrip
2017-12-05 21:32:10 +00:00
with-subkey-fingerprint
2019-05-03 15:44:02 +00:00
keyserver-options include-revoked
2017-12-05 21:32:10 +00:00
avoid DL/UL issues, depending on DNS
------------------------------------
* dirmngr.conf
::
standard-resolver
Generate
========
master key
----------
.. code:: shell
2019-05-03 12:04:29 +00:00
gpg --expert --full-generate-key
2017-12-05 21:32:10 +00:00
::
2019-05-03 12:04:29 +00:00
8 → RSA (set your own capabilities)
s → toggle the sign capability
e → toggle the encrypt capability
q → finished
2019-05-03 12:22:25 +00:00
4096
2019-05-03 12:04:29 +00:00
2y → key expires in 2 years
2017-12-05 21:32:10 +00:00
y → this is correct
First Last
user@domain.tld
2019-05-03 12:04:29 +00:00
comment
2017-12-05 21:32:10 +00:00
o → ok
2019-05-03 15:35:46 +00:00
.. code:: shell
gpg --quick-generate-key 'First Last <user@domain.tld>' rsa4096 cert 2y
2017-12-05 21:32:10 +00:00
revocation certificate
----------------------
.. code:: shell
gpg --generate-revocation "KeyID" > "FFIINNGGEERRPPRRIINNTT.rev"
2019-05-03 15:40:13 +00:00
::
y
::
0 → no reason specified
1 → key has been compromised
2 → key is superseded
3 → key is no longer used
::
description
y
2017-12-05 21:32:10 +00:00
.. warning::
Hide this file in an encrypted container!
Search
======
.. code:: shell
gpg --search-keys "Key ID"
Download
========
.. code:: shell
gpg --receive-keys "KEY ID"
List
====
.. code:: shell
gpg --list-keys
Modify
======
.. code:: shell
2019-05-03 12:24:03 +00:00
gpg --expert --edit-key "KEY ID"
2017-12-05 21:32:10 +00:00
[…]
::
save
add a subkey to a master key
----------------------------
::
addkey
2019-05-03 12:24:03 +00:00
8 → RSA (set your own capabilities)
[…]
::
q → finished
4096
1y → key expires in 1 year
y → this is correct
y → really create
sign
^^^^
::
e → toggle the encrypt capability
2019-05-03 15:35:46 +00:00
.. code:: shell
gpg --quick-add-key FFIINNGGEERRPPRRIINNTT rsa4096 auth 1y
gpg --quick-add-key FFIINNGGEERRPPRRIINNTT rsa4096 encr 1y
gpg --quick-add-key FFIINNGGEERRPPRRIINNTT rsa4096 sign 1y
2019-05-03 12:24:03 +00:00
encrypt
^^^^^^^
::
s → toggle the sign capability
authenticate
^^^^^^^^^^^^
::
s → toggle the sign capability
e → toggle the encrypt capability
a → toggle the authenticate capability
2017-12-05 21:32:10 +00:00
set expiration date
-------------------
::
expire
2019-05-03 15:40:13 +00:00
1y
y
2017-12-05 21:32:10 +00:00
add another UserID
------------------
::
adduid
First Last
user@domain.tld
2019-05-03 15:40:13 +00:00
comment
o
2017-12-05 21:32:10 +00:00
set primary UserID
------------------
::
uid 1
primary
Export
======
2019-05-03 17:07:54 +00:00
public key
----------
2017-12-05 21:32:10 +00:00
.. code:: shell
gpg --armor --export "Key ID" > pub.asc
2019-05-03 17:07:54 +00:00
private key
-----------
.. code:: shell
gpg --armor --export-secret-keys FFIINNGGEERRPPRRIINNTT > key.gpg
private subkeys
---------------
.. code:: shell
gpg --armor --export-secret-subkeys FFIINNGGEERRPPRRIINNTT > subkeys.gpg
2017-12-05 21:32:10 +00:00
Dump
====
.. code:: shell
pgpdump pub.asc
Secure
======
hide the master key in an encrypted container
---------------------------------------------
* ~/.gnupg/private-keys-v1.d/KKEEYYGGRRIIPP.key
Upload
======
.. code:: shell
gpg --send-keys "KEY ID"
Revoke
======
.. code:: shell
gpg --import "FFIINNGGEERRPPRRIINNTT.rev"
gpg --send-keys "KEY ID"