GPG super-mini HOWTO
#– Generate your key
[user@host ~]$ gpg –gen-key
gpg (GnuPG) 1.2.6; Copyright (C) 2004 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.
gpg: failed to create temporary file `/home/user/.gnupg/.#lk0x94809a8.host.20525′: No such file or directory
gpg: /home/user/.gnupg: directory created
gpg: new configuration file `/home/user/.gnupg/gpg.conf’ created
gpg: WARNING: options in `/home/user/.gnupg/gpg.conf’ are not yet active during this run
gpg: keyring `/home/user/.gnupg/secring.gpg’ created
gpg: keyring `/home/user/.gnupg/pubring.gpg’ created
Please select what kind of key you want:
(1) DSA and ElGamal (default)
(2) DSA (sign only)
(4) RSA (sign only)
Your selection? 1
DSA keypair will have 1024 bits.
About to generate a new ELG-E keypair.
minimum keysize is 768 bits
default keysize is 1024 bits
highest suggested keysize is 2048 bits
What keysize do you want? (1024) 2048
Requested keysize is 2048 bits
Please specify how long the key should be valid.
0 = key does not expire
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 Real Name, Comment and Email Address in this form:
“Heinrich Heine (Der Dichter)
Real name: USER NAME
Email address: EMAIL@MAIL.SERVER
Comment: GPG TEST
You selected this USER-ID:
“USER NAME (GPG TEST)
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o
You need a Passphrase to protect your secret key.
Enter passphrase:
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: /home/hctseng/.gnupg/trustdb.gpg: trustdb created
public and secret key created and signed.
key marked as ultimately trusted.
pub 1024D/16305049 2006-09-08 USER NAME (GPG TEST)
Key fingerprint = 047A F5B1 8A8D 078B A187 70D3 3638 1FDC 1630 5049
sub 2048g/ED3B7D53 2006-09-08
#– This is a regular file ready for encrypt.
[user@host ~]$ cat testfile
this is a test.
#– Before you encrypt, please make should you have keys
[user@host ~]$ gpg –list-key
/home/user/.gnupg/pubring.gpg
——————————–
pub 1024D/16305049 2006-09-08 USER NAME (GPG TEST)
sub 2048g/ED3B7D53 2006-09-08
#– Start to encrypt the testfile
[user@host ~]$ gpg -e testfile
You did not specify a user ID. (you may use “-r”)
Enter the user ID. End with an empty line: user name
gpg: checking the trustdb
gpg: checking at depth 0 signed=0 ot(-/q/n/m/f/u)=0/0/0/0/0/1
Added 2048g/ED3B7D53 2006-09-08 “USER NAME (GPG TEST)
Enter the user ID. End with an empty line:
#– Now, you do not need the origanal file any more.
[user@host ~]$ rm testfile
#– The filename.gpg was created by gpg encrypt
[user@host ~]$ ls testfile*
testfile.gpg
#– Let’s decrypt it
[user@host ~]$ gpg -d testfile.gpg > testfile
You need a passphrase to unlock the secret key for
user: “USER NAME (GPG TEST)
2048-bit ELG-E key, ID ED3B7D53, created 2006-09-08 (main key ID 16305049)
gpg: encrypted with 2048-bit ELG-E key, ID ED3B7D53, created 2006-09-08
“USER NAME (GPG TEST)
#– your file is back. 🙂
[user@host ~]$ cat testfile
this is a test.