Using GnuPG

GnuPG is the GNU Privacy Guard, the open source equivalent to Pretty Good Privacy (PGP). You can use GnuPG to encrypt and/or sign your mails or files and hence transmit them in a more secure fashion and ensure their integrity.

There are graphical environments to handle GnuPG but here we are going to use text-based commands.

First of all me must generate a key pair:

gpg –gen-key

The first time you run this command it will create some directories and files, so you need to launch the command again to create the keyrings.

When prompted select these options:

DSA and ElGamal
Keysize 1024
Expire time 0 (never expires)
Personal info
Passphrase

For the moment accepting default values is fine. Be careful with your passphrase as it will be used to encrypt/decrypt and sign your data, so do not simply choose the first silly words you guess ;-)

Once you have your key-pairs, you are ready to start using GnuPG.

gpg -ea -r karkoma myfile.txt

Encrypts myfile.txt using karkoma’s public key with an ASCII armor (more on this in my next article).

gpg -d myfile.txt.asc >myfile.txt

Decrypts myfile.txt.asc (enter your passphrase)

gpg –clearsign -a myfile.txt

Signs myfile.txt. Once signed, the smallest modification to the file will indicate an invalid signature.

gpg –verify myfile.txt.asc

Verifies your file signature.

gpg -ba myfile.tar.gz

Signs a binary file

That’s all folks, just for now. I am preparing a more complete article regarding GnuPG, so come back soon.

3 Responses to “Using GnuPG”

  1. karkoma says:

    This an enhancement taken from gentoo.org…

    Using GnuPG to digitally sign emails.

    GNU Privacy Guard (GnuPG) is an open source version of the commercial Pretty Good Privacy (PGP) software for creating digital signatures. Next paragraphs will cover the creation of a key, exporting your key to a public keyserver, and finally adding your digital signature to email.

    a) Installing GnuPG and creating your directory

    emerge gnupg
    mkdir $HOME/.gnupg

    b) Creating a new key

    gpg –gen-key

    you should select ‘DSA and ElGamal’, ’1024′ as keysize, no expiration date for your key (be careful with this) and your personal data (name, email) and finally your passphrase.

    Now that your key has been made, it needs to be exported to a public keyserver. While this is not required, it’s the easiest way for others to get your public key information and verify your information. To send your key, you’ll first need to know your Key ID.

    c) Find your key ID

    gpg –list-keys

    /home/johndoe/.gnupg/pubring.gpg
    ——————————-
    pub 1024D/XXXXXXXX 2003-12-12 John Doe john.doe@example.com
    sub 1024g/ZZZZZZZZ 2003-12-12

    Note that XXXXXXXX and ZZZZZZZZ and the rest of data are fictitious.

    d) Now you can export your key to a public server

    gpg –send-keys –keyserver wwwkeys.pgp.net XXXXXXXX

    Now that your key has been created and published, you can start using it to sign emails. You’ll need to remember your Key ID for this step. If you don’t remember it, see the above code listing, step c).

    Use the following steps to set up encryption in Evolution:

    1. Click on Tools->Settings.
    2. Select “Mail Accounts” button and the account that will be using the key.
    3. Click Edit and then the Security tab. Enter your Key ID in the field entitled PGP/GPG Key ID.
    4. Click OK.

    Now when you compose a message, select Security->PGP Sign to add your digital signature to your email.

  2. Anonymous says:

    There is also support for other Linux/Unix email clients that are freely available and work well.

    For kmail() and mutt(), you will need to install the packages gnupg, libgpgme, and cryptoplug. Add the following statement to ~/.xinitrc

    “$(gpg-agent –daemon)”

    The gpg-agent() holds your private key in non-swapable memory, very similar to ssh-agent() and makes it available to the kmail plugin.

    Now, add the following to ~/.gnupg/gpg-agent.conf

    pinentry-program /usr/bin/pinentry-qt
    no-grab
    default-cache-ttl 1800

    These statements define the popup window to be used by gpg-agent.

    Finally, within kmail:/Settings/Configure Kmail||Security/Cryptoplugins: select /usr/bin/crytoplug/gpgme-openpgp.so. Activate the plugin.

    Send yourself a signed email to see if kmail colors it in pale green.

    Mozilla and Mozilla Thunderbird are considerably easier to enable in PGP. Simply install the Enigmail plugin from within Tbird: /Tools/Options/Extensions|Get New Extensions.

    Restart Tbird and configure under the “Enigmail” menu.

    Again, send yourself a signed email and see if the Enigmail plugin will color the header bar correctly.

    If in either case, the client shows your test message as anything other than green, it’s probably due to your “trust” settings in gpg() . Try:

    gpg –update-trustdb

    Tell it that you “ultimately” trust your own key.

  3. Anonymous says:

    Ummm… very nice!

Leave a Reply

You must be logged in to post a comment.