GnuPG In 10 Minutes

Encrypted

If you need to secure communication or encrypt personal / sensitive data, GnuPG is the tool. Its free, and available for download from Gnu's Website or install from Debian repositories.

GnuPG is a free clone of PGP (PrettyGoodPrivacy), cryptographic software.

To find it on Debian, do:

aptitude search gnupg

To install:

aptitude install gnupg

To use GnuPG first, you generate your key:

gpg --gen-key

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? 

Select # 1

RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 

Accept and press [ Enter ]

Please specify how long the key should be valid.
      0 = key does not expire
        = key expires in n days
      w = key expires in n weeks
      m = key expires in n months
      y = key expires in n years
Key is valid for? (0) 
Key does not expire at all
Is this correct? (y/N) 

Press 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) "

Real name: [ Enter your name here ]
Email address: [ Enter your email address here ]
Comment: [ Enter a comment or leave blank ]
You selected this USER-ID:
    "Your Name "

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? 

[ Press 'O' to accept settings ]

You need a Passphrase to protect your secret key.

[ Type a memorable phrase. You will need it later. ]

GnuPG will generate and display your key. Something like:

pub   2048R/8E6D74A2 2010-12-31
uid                  Your Name
sub   2048R/AD17E388 2010-12-31

The first line displays my key: 8E6D74A2. 

First entry identifies my public key: pub. 
I used 2048 bits to generate the key: 2048R/
The date my key was created: 2010-12-31

You can see my key is 8E6D74A2.

To encrypt a file:

gpg --output myfile.gpg --encrypt --recipient myfile.txt

GnuPG creates an output file called myfile.gpg which is encrypted and is generated for recipient using myfile.txt as input file.

To decrypt a file:

gpg --output myfile --decrypt myfile.gpg

You will need to give your memorable passphrase to decrypt the file.

To generate your public key:

gpg --armor --export myemail@address > mypubkey

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.10 (GNU/Linux)

mQENBE0dNWMBCACZtfh/236A9Gul+e8L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VBCRliMZ0QSrypcYaVc6Co8X1x4Xx+ls69f/8pxDW3sXpEgkBEIIO+F0+
1tVoarnz/tzcnPHG1sr4XltSA/KLlxsHf1vt/0XdRSHXABEBAAGJAR8EGAECAAkF
Ak0dNWMCGwwACgkQeC8Mm45tdKJtwAf+LbHF4AbHA0pBvSPqawl0YnFaKfj/wJIp
Tu3noYh/n7uSCswtBF9UvJrN5+rHmr/H7aEP47OOxphkQtUhaDT0pFiRhqXKt8YW
A9a+0ubHzQWfxOX+kQ/O9RdM9/hVNdjYMO9MsT6AjP/FHtsMU478bUf3Yd8rdcQI
kkg4T1OluqHTrvCZQn/yPwH08B/Que9NFZTTVtpOetkZXSprOUjIcGK60YI8ysGm
RnqkTASpFMNwTk2EyApIChfoUWn0lBO1JLIXqweTzTsVA2JkJm6hTQgq8wvRHpYH
0eE+IIJEnR/hSFvCwpCWtb2uzGwM5inXeDImc7r4t7lWz09c2VqWkQ===7WdN
-----END PGP PUBLIC KEY BLOCK----

GnuPG generates my public key. I can display the key on my website, or send it via email to people I know and trust who wish to send me secure messages or files. 

That covers some uses of GnuPG. Its worth reading the online GnuPG Handbook.