Security: Step by step directions for setting up your private key using gpg
Here are the steps for generating your own Public and Private keys using gpg.
Only do this on a clean computer that you are certain you can trust that it has not been compromised.
1) Type: gpg –gen-key
2) Press <Enter>
3) Follow the prompts and answer each question
youruser@yourcomputer:~$ gpg –gen-key
gpg (GnuPG) version#; Copyright (C) year Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Please select what kind of key you want:
(1) RSA and RSA (default)
(2) DSA and Elgamal
(3) DSA (sign only)
(4) RSA (sign only)
Your selection? 1
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 4096
Requested keysize is 4096 bits
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
Key is valid for? (0) 0
Key does not expire at all
Is this correct? (y/N) y
You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
“Heinrich Heine (Der Dichter) <[email protected]>”
Real name: FirstName LastName
Email address: [email protected]
Comment:
You selected this USER-ID:
“FirstName LastName <[email protected]>”
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
You need a Passphrase to protect your secret key.
4) GPG will take a few minutes processing your new key, so go about using your computer as normal until you see that is has completed.
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
Not enough random bytes available. Please do some other work to give
the OS a chance to collect more entropy! (Need 187 more bytes)
…………….+++++
Not enough random bytes available. Please do some other work to give
the OS a chance to collect more entropy! (Need 248 more bytes)
……………………+++++
gpg: key C4C3FB44 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 4096R/C4C3FB44 2016-07-11
Key fingerprint = 3CC3 356A 33AB 5411 1AA2 5211 AD13 351A C4C3 FB44
uid FirstName LastName <[email protected]>
sub 4096R/DD21DA31 2016-07-11
5) Once this completes, you can now look at the keys in your keystore
6) Type: gpg –list-keys
7) Press <Enter>
youruser@yourcomputer:~$ gpg –list-keys
/home/tconrad/.gnupg/pubring.gpg
——————————–
pub 4096R/C4C3FB44 2016-07-11
uid FirstName LastName <[email protected]>
sub 4096R/DD21DA31 2016-07-11
8)At this point, I would suggest exporting your keys and store them in a trusted secured location.
9) Type: gpg –export-secret-key -a “yourkeyID or Name” > your-priv.key
tconrad@IS005156:~$ gpg –export-secret-key -a C4C3FB44 > your-priv.key
10) Type: gpg –export -a “yourkeyID or Name” > your-pub.key
tconrad@IS005156:~$ gpg –export -a C4C3FB44 > your-pub.key
11) Finally if this is not the computer you will decrypt on I would suggest deleting your private key off of it as long as you have back it up to a secure location following the above steps.
12) Type: gpg –delete-secret-key “yourkeyID or Name”
13) Follow the prompts
youruser@yourcomputer:~$ gpg –delete-secret-key C4C3FB44
gpg (GnuPG) 1.4.20; Copyright (C) Copyright Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
sec 4096R/C4C3FB44 2016-07-11 FirstName LastName <[email protected]>
Delete this key from the keyring? (y/N) y
This is a secret key! – really delete? (y/N) y
14) Enjoy your new encryption option
By: Timothy Conrad
This post was inspired by Citizenfour and Laura Poitras