Recipe "How to create, configure, export and import GnuPG keys"
Component 947749
Jump to navigation
Jump to search
|
Content
Notice:
- The following steps are valid for Ubuntu as the workstation's operating system.
- Background:
Instructions
Create a key pair
Install rng-tools
In order to increase the quantity of entropy in kernel to make /dev/random faster, install rng-tools, which is a set of utilities related to random number generation in kernel.
user@workstation:~$ sudo apt-get install rng-tools user@workstation:~$ sudo rngd -r /dev/urandom
Generate the key pair
user@workstation:~$ gpg --gen-key
- Choose RSA and RSA (default) for both encryption and signing.
- Set keysize
- Set expiration
- Set real name + e-mail address + comment
- Set passphrase
- Do random bytes activity
This will result in something looking akin to this:
gpg: key 944CBA14 marked as ultimately trusted public and secret key created and signed. gpg: checking the trustdb gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u pub 1024R/944CBA14 2014-09-12 Key fingerprint = 1D09 09E0 5F7B 3600 CDBE 5FF3 BF68 E00C 944C BA14 uid Yogi Joghurt (Your comment) <yogi@lcc.com> sub 1024R/7167B984 2014-09-12
Notice:
944CBA14 is the key-id
Add key as default key to $HOME/.bashrc
user@workstation:~$ echo "export GPGKEY=944CBA14" >> $HOME/.bashrc
user@workstation:~$ source $HOME/.bashrc
List keys
List public keys
user@workstation:~$ gpg --list-keys
/home/user/.gnupg/pubring.gpg
-----------------------------
pub 1024R/944CBA14 2014-09-12
uid Yogi Joghurt (Your comment) <yogi@lcc.com>
sub 1024R/7167B984 2014-09-12
List secret/private keys
user@workstation:~$ gpg --list-secret-keys
/home/user/.gnupg/secring.gpg
-----------------------------
sec 1024R/944CBA14 2014-09-12
uid Yogi Joghurt (Your comment) <yogi@lcc.com>
ssb 1024R/7167B984 2014-09-12
Backup keys
Backup public key
user@workstation:~$ gpg --armor --output <arbitrary name>-public.key --export 944CBA14
Backup private key
user@workstation:~$ gpg --armor --output <arbitrary name>-private.key --export-secret-keys 944CBA14
Import GPG keys for OS user
user@workstation:~$ gpg --import public_key.gpg user@workstation:~$ gpg --allow-secret-key-import --import secret_key.gpg
Configure GPG keys
user@workstation:~$ gpg --edit-key 944CBA14
...
gpg>
Set trust level
gpg> trust
Change passphrase
gpg> passwd
Exit gpg prompt
gpg> quit