We're going to assume that Mary Jo wants to receive secure communication
from Sam. Here's how she sets it up.
First step is for Mary Joe to generate her key:
mjj@example.com:~$ gpg --gen-key
In order to generate the key, gpg will ask Mary Jo a series of questions:
gpg (GnuPG) 1.4.9; Copyright (C) 2008 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) DSA and Elgamal (default)
(2) DSA (sign only)
(5) RSA (sign only)
Your selection?
Mary Jo simple selects the default.
DSA keypair will have 1024 bits.
ELG-E keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
And again, she accepts the default.
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)
This is an interesting question. How long should the key be valid? If the
key never expires, and the key becomes compromised (i.e., Mary Jo loses her
private key), then anything encrypted with it will be compromised. On the
other hand, if the key expires in 1 day, she'll constantly be creating
new keys. A reasonable compromise? I'd say six months to one year.
Key is valid for? (0) 6m
Key expires at Wed 02 Jun 2010 01:29:22 PM PDT
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) <heinrichh@duesseldorf.de>"
Real name:
Now Mary Jo is asked to fill in identifying information.
Real name: Mary Jo Jones
Email address: mjj@example.com
Comment:
You selected this USER-ID:
"Mary Jo Jones <mjj@example.com>"
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o
You need a Passphrase to protect your secret key.
Enter passphrase:
The passphrase is a long string that only Mary Jo knows. What's appropriate
here? Something long with lowercase and uppercase letters, numbers and
punctuation. And something she won't have to write down to remember.
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.
.+++++.+++++.+++++++++++++++.++++++++++.+++++++++++++++.++++++++++.+++++.+++++..
+++++++++++++++++++++++++.++++++++++.++++++++++++++++++++++++++++++..>+++++.....
............................................+++++
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.
+++++.++++++++++++++++++++++++++++++++++++++++.+++++..+++++++++++++++...+++++..+++
++..+++++..++++++++++.++++++++++.++++++++++++++++++++...+++++..+++++++++++++++..++
+++>++++++++++>+++++>+++++.................................>+++++.................
..........................................................+++++^^^
gpg: key 8888BBD4 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: 2 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 2u
gpg: next trustdb check due at 2010-06-02
pub 1024D/8888BBD4 2009-12-04 [expires: 2010-06-02]
Key fingerprint = C61E 14EC 8078 AC8C 59A6 D909 7B07 6A08 8888 BBD4
uid Mary Jo Jones <mjj@example.com>
sub 2048g/092F4D36 2009-12-04 [expires: 2010-06-02]
That's it! Mary Jo has created a public and private key.
Now she needs to share her public key with others. It doesn't matter who
knows the public key. Public keys are, after all, meant to be public. But
her point in doing this is that she wants Sam to have it, so that Sam can
send her private messages.
Mary Jo must export the public key.
mjj@example.com:~$ gpg --armor --export "Mary Jo Jones"
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.9 (GNU/Linux)
mQGiBEsZcSIRBACmAct8gJeyp84JaZw7mkvx3rVwlkaYMkG4whQ9kVutYHlgzr+8
GhQVB1XEnXfAZdqO2/7vTIZJW3cbjMYkDXFhknXMbIQMUMyEt6N97gpQfw38mXaq
7eYppwjQiiw1vIKmtQl0AkMVhvK6MQVmwwk7U4kAN9o5XG8vLJubG0uFvwCgrw+K
a9k/mEYRjKsS6Zidxrd5s0MD/jvIt6aSdE4nXv2lAx76l/mdvXFvHoJD8N1+zQ04
WM9RA8C7lo96JiBLsqwRR8r9JaoinwSFKegMCR5p/KWjp8MxyBaKHqd4pt5X1Ax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31RLGImz9UHLp+52
E0LiMU54V3A8aasViQco2gNpjKjPJprpYTOmUKjSiE8EGBECAA8FAksZcSICGwwF
CQDtTgAACgkQewdqCIiIu9ReSgCgqObqN6FkRwk+9KP01EcpMc9BP4IAoJmKd6xA
wjNXz+WB4+hUzPX7lahQ
=TN4y
-----END PGP PUBLIC KEY BLOCK-----
Now Mary Jo cuts and pastes this into an email to Sam. Sam will then
import this key into his keyring. Let's assume that Sam puts the key into a
file called key.
sam@example.com:~$ ls
key
sam@example.com:~$ gpg --import key
gpg: directory `/home/sam/.gnupg' created
gpg: new configuration file `/home/sam/.gnupg/gpg.conf' created
gpg: WARNING: options in `/home/sam/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/home/sam/.gnupg/secring.gpg' created
gpg: keyring `/home/sam/.gnupg/pubring.gpg' created
gpg: /home/sam/.gnupg/trustdb.gpg: trustdb created
gpg: key 8888BBD4: public key "Mary Jo Jones <mjj@example.com>" imported
gpg: Total number processed: 1
gpg: imported: 1