D&C Lug - Home Page
Copyright © 2003 Neil Williams. Copyright © 1999 by The Free Software Foundation
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".
 

Getting Started with GnuPG

This document:

GNU/Linux documentation at DCGLUG.

What is GnuPG/PGP

GnuPG is an open source implementation of the proprietary Pretty Good Privacy (PGP), both act as tools for secure communication by providing each user with a pair of keys; a private key and a public key. A user's private key is kept secret; it need never be revealed. The public key may be given to anyone with whom the user wants to communicate. Unless specialised key functions are used, keys created with PGP are usually interchangeable with keys created with GnuPG and vice versa.

Top
 

Why two keys?

A public and private key each have specific roles when signing, encrypting or decrypting documents.

Top
 

How do I generate a key for the first time?

The normal way to create a key is:
gpg --gen-key
This asks some questions and then starts key generation. To create good random numbers for the key parameters, GnuPG needs to gather enough noise (entropy) from your system. If you see no progress during key generation you should start some other activities such as mouse moves or hitting on the CTRL and SHIFT keys.

Generate a key ONLY on a machine where you have direct physical access - don't do it over the network or on a machine used also by others - especially if you have no access to the root account.

Next, you should create a revocation certificate in case someone gets knowledge of your secret key or you forget your passphrase:
gpg --gen-revoke your_user_id

Run this command and store the revocation certificate away. The output is always ASCII armored, so that you can print it and (hopefully never) re-create it if your electronic media fails.

Top
 

What protects my private key?

YOU! Protecting the private key is the most important job of the key owner.

To help safeguard your key, GnuPG does not store your raw private key on disk. Instead it encrypts it using a symmetric encryption algorithm. That is why you need a passphrase to access the key. Thus there are two barriers an attacker must cross to access your private key:

Top
 

What kind of passphrase is needed?

A good passphrase is absolutely critical when using GnuPG. Any attacker who gains access to your private key must bypass the encryption on the private key. Instead of brute-force guessing the key, an attacker will almost certainly instead try to guess the passphrase. The security of the whole system relies on your secret key and the passphrase that protects it when someone gains access to your secret keyring.

The motivation for trying passphrases is that most people choose a passphrase that is easier to guess than a random 128-bit key. If the passphrase is a word, it is much cheaper / quicker / easier to try all the words in the dictionaries of the world's languages. Even if the word is permuted, e.g., k3wldood, it is still easier to try dictionary words with a catalog of permutations. The same problem applies to quotations. In general, passphrases based on natural-language utterances are poor passphrases since there is little randomness and lots of redundancy in natural language. You should avoid natural language passphrases if you can.

A good passphrase is one that you can remember but is hard for someone to guess. It should include characters from the whole range of printable characters on your keyboard. This includes uppercase and lowercase alphabet characters - A to Z and a to z, numbers 0 to 9, and special characters such as } and # and |. Be creative and spend a little time considering your passphrase; a good choice is important to ensure your privacy. You can change your passphrase at any time, without affecting your public key.

Top
 

What protects my public key?

A public key can be protected from tampering by using self-singing to bind the components of the key together. When you generate a new keypair, the new private key is used to sign the new public key components and user IDs. A self-signed public key can not be modified by adding or substituting keys, or by adding or changing user IDs without the matching private key. When you distribute your public key, you are distributing the public components of your master and subordinate keys as well as the user IDs. Distributing this material without a self-signature would be a security risk since it would be possible for an attacker to tamper with the key. By default GnuPG creates self-signed public keys.

Top
 

How should I publish my public key?

Ideally, you would distribute your public key by personally giving it to your correspondents. In practice, however, public keys are often distributed by email or some other electronic communication medium. Distribution by email is good practice when you have only a few correspondents, and even if you have many correspondents, you can use an alternative means such as posting your public key on your World Wide Web homepage. This is unacceptable, however, if people who need your public key do not know where to find it on the Web.

To solve this problem public key servers are used to collect and distribute public keys. A public key received by the server is either added to the server's database or merged with the existing key if already present. When a key request comes to the server, the server consults its database and returns the requested public key if found. A keyserver is also valuable when many people are frequently signing other people's keys because the server takes over all the hassle of keeping existing public keys updated with new signatures or user ID's.

Keep in mind, though, that this is optional. You have no obligation to either sign other people's keys or publicly advertise your public key (if you don't sign or encrypt email). The social reality, however, is that you will need to publicise your public key if you want to grow your web of trust and use GnuPG for as much of your communication as possible.

The power of GnuPG is that it is flexible enough to adapt to your security needs whatever they may be. You can use one keypair for email signing and email encryption and use a completely different, un-publicised, keypair for local encryption of personal data. How you should use GnuPG depends on the determination and resourcefulness of those who might want to read your encrypted messages or pretend to be you using signed documents. Using GnuPG to protect against casual eavesdropping is going to be different than using GnuPG to protect against a determined adversary. Your goal, ultimately, is to make it more expensive to recover the unencrypted data than that data is worth.

Top
 

What is key signing?

The core of key management in GnuPG is the notion of signing keys. Key signing has two main purposes:

A correspondent's key is validated by personally checking his key's fingerprint and then signing his public key with your private key. By personally checking the fingerprint you can be sure that the key really does belong to him, and since you have signed they key, you can be sure to detect any tampering with it in the future.

Unfortunately, this procedure is awkward when either you must validate a large number of keys or communicate with people whom you do not know personally. GnuPG addresses this problem with a mechanism popularly known as the web of trust. In the web of trust model, responsibility for validating public keys is delegated to people you trust.

For more information on what is needed before signing a key, see the D&C LUG Keysigning FAQ and the archives: Exeter area D&C LUG meeting Plymouth evening meeting Tue 20-5-03 or the GnuPG Keysigning Party HOWTO.

You should always be careful when signing other keys. It is selfish to sign a key with just enough confidence in the key's validity to satisfy your own security needs. Others, with more stringent security needs, may want to depend on your signature. If they cannot depend on you then that weakens the web of trust and makes it more difficult for all GnuPG users to communicate. Use the same care in signing keys that you would like others to use when you depend on their signatures.

Top
 

What is the Web of Trust (WoT)?

The web of trust is used to extend certification to keys not directly signed by you but signed by other people you already trust. A key in the web of trust is considered valid if it meets two conditions:

The path length, number of marginally trusted keys required, and number of fully trusted keys required may be adjusted. In general, higher numbers for these options imply that more people would be needed to conspire against you in order to have a key validated that does not actually belong to the person whom you think it does. The numbers given above are the default values used by GnuPG.

Top
 

How do I manage and build my WoT?

As with protecting your private key, managing your web of trust is another aspect of using GnuPG that requires balancing security against ease of use. If you are using GnuPG to protect against casual eavesdropping and forgeries then you can afford to be relatively trusting of other people's signatures. On the other hand, if you are concerned that there may be a determined attacker interested in invading your privacy, then you should be much less trusting of other signatures and spend more time personally verifying signatures.

If you do not personally know the person whose key you want to sign, then it is not possible to sign the key yourself. You must rely on the signatures of others and hope to find a chain of signatures leading from the key in question back to your own. To have any chance of finding a chain, you must take the initiative and get your key signed by others outside of your initial web of trust. An effective way to accomplish this is to participate in key signing parties. If you are going to a conference look ahead of time for a key signing party, and if you do not see one being held, offer to hold one. You can also be more passive and carry your fingerprint with you for impromptu key exchanges. In such a situation the person to whom you gave the fingerprint would verify it and sign your public key once he returned home.

At first glance, building a web of trust is a daunting task. The people with whom you communicate need to use GnuPG, and there needs to be enough key signing so that keys can be considered valid. These are not technical problems; they are social problems. Nevertheless, you must overcome these problems if you want to use GnuPG.

When getting started using GnuPG it is important to realize that you need not securely communicate with every one of your correspondents. Start with a small circle of people, perhaps just yourself and one or two others who also want to exercise their right to privacy. Generate your keys and sign each other's public keys. This is your initial web of trust. By doing this you will appreciate the value of a small, robust web of trust and will be more cautious as you grow your web in the future.

In addition to those in your initial web of trust, you may want to communicate securely with others who are also using GnuPG. Doing so, however, can be awkward for two reasons:

The first reason occurs because people do not always advertise that they use GnuPG. The way to change this behavior is to set the example and advertise that you use GnuPG. There are at least three ways to do this:

If you advertise your key then you make it that much more acceptable for others to advertise their keys. Furthermore, you make it easier for others to start communicating with you securely since you have taken the initiative and made it clear that you use GnuPG.

Top
 

How should I manage my keypair?

Good key management is crucial in order to ensure not just the integrity of your keyrings but the integrity of other users' keyrings as well. Responsible users who practice good key management can defeat key tampering as a practical attack on secure communication with GnuPG.

Regardless of how you use GnuPG you should store the public key's revocation certificate and a backup of your private key on write-protected media in a safe place. For example, you could burn them on a CD-ROM and store them in your safe deposit box at the bank in a sealed envelope. Alternatively, you could store them on a floppy and hide it in your house. Whatever you do, they should be put on media that is safe to store for as long as you expect to keep the key, and you should store them more carefully than the copy of your private key you use daily.

Safely storing your private key is important, but there is a cost. Ideally, you would keep the private key on a removable, write-protected disk such as a floppy disk, and you would use it on a single-user machine not connected to a network. This may be inconvenient or impossible for you to do. For example, you may not own your own machine and must use a computer at work or school, or it may mean you have to physically disconnect your computer from your cable modem every time you want to use GnuPG.

This does not mean you cannot or should not use GnuPG. It means only that you have decided that the data you are protecting is important enough to encrypt but not so important as to take extra steps to make the first barrier stronger. It is your choice.

Top
 

When, why and how would I revoke the key?

When: There are two main circumstances where you would need to revoke the key.

  1. If someone else obtains the secret key AND passphrase - the key is now termed compromised. Time is important here - revoke the key (see below for the commands) immediately you discover that it has been compromised. Send the revoked key to keyservers and then generate a new key. All keys that you signed with the old key can now be signed with the new key and then updated on keyservers using --send-keys. Notify all your regular correspondents of the compromised key and include the fingerprint of both keys, signing the encrypted emails with the new key (your email software will encrypt to the recipient key and optionally save a copy of the email locally, encrypted to your own key so make sure your email software is using the new key!). Ask each user to refresh their own key so that your signatures with your new key will show up. You will have to make individual arrangements to transfer each signature from the revoked key to the new key. Depending on how the key became compromised, some signatories may not wish to sign your new key.
  2. If you forget the passphrase. Generate a new key and revoke the old key. Unfortunately, without the passphrase, you cannot easily arrange for signatures on your old key to be transferred to the new key. Identify all keys that you signed with the old key and sign them again with the new key. Now send encrypted emails to each signatory on the old key explaining your amnesia and include the fingerprint of both keys. Ask each signatory to refresh their own keys and then download your new key. Sign each email with the new key. As you can no longer decrypt messages sent to the old key because of your amnesia, you will have to verify the new key with each correspondent before they can sign your new key - try and arrange a meeting and follow the usual keysigning procedures.
Top of page - Top of this section
 

Why revoke keys?

  1. Compromised keys need to be revoked so that your correspondents can prevent encrypted data being sent to the attacker. You need to alert each correspondent because revoked keys only show up if the key is refreshed, usually using a keyserver, and people don't refresh known keys that often. Until each correspondent has been alerted, encrypted data will continue to be sent to the wrong key and is therefore readable by the attacker who compromised the key in the first place. Don't assume that the attacker will keep such data to themselves!
  2. Forgotten keys need to be revoked so that your correspondents stop sending encrypted data that you can no longer read! You can notify all regular correspondents, but this doesn't prevent new correspondents from still using the key, until it is revoked.
Top of page - Top of this section
 

How do I revoke a key? Have you successfully generated a revocation certificate?

  1. Yes : You need to send it to the key servers. Most keyservers don't accept a 'bare' revocation certificate, so import the certificate into gpg first:
    gpg --import my-revocation.asc
    gpg adds the certificate to the public key and you can then send the revoked key to the keyservers:
    gpg --keyserver subkeys.pgp.net --send-keys mykeyid
  2. No.
    1. Compromised keys can still be revoked by generating the revocation certificate at the time of the compromise. Create a revocation certificate using:
      gpg --output my-revocation.asc --gen-revoke your_user_id.
      Now import the certificate as above.
    2. Forgotten keys are more of a problem. You will have to make every effort to notify regular correspondents of your problem and acknowledge that you didn't take the precaution of generating the revocation certificate beforehand. The key cannot be revoked without the passphrase or a revocation certificate, so you should also put an explanation on your home page to help new correspondents to use the new key.
Top of page - Top of this section
 
Appendix A. GNU Free Documentation License
Version 1.1, March 2000
Copyright (C) 2000 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

0. PREAMBLE

The purpose of this License is to make a manual, textbook, or other written document "free" in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.
This License is a kind of "copyleft", which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.
We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.

1. APPLICABILITY AND DEFINITIONS

This License applies to any manual or other work that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. The "Document", below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as "you".
A "Modified Version" of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.
A "Secondary Section" is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (For example, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.
The "Invariant Sections" are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License.
The "Cover Texts" are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License.
A "Transparent" copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, whose contents can be viewed and edited directly and straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup has been designed to thwart or discourage subsequent modification by readers is not Transparent. A copy that is not "Transparent" is called "Opaque".
Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML designed for human modification. Opaque formats include PostScript, PDF, proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML produced by some word processors for output purposes only.
The "Title Page" means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, "Title Page" means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text.

2. VERBATIM COPYING

You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and you may publicly display copies.

3. COPYING IN QUANTITY

If you publish printed copies of the Document numbering more than 100, and the Document's license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.
If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a publicly-accessible computer-network location containing a complete Transparent copy of the Document, free of added material, which the general network-using public has access to download anonymously at no charge using public-standard network protocols. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.
It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.

4. MODIFICATIONS

You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version: If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles.
You may add a section entitled "Endorsements", provided it contains nothing but endorsements of your Modified Version by various parties--for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.
You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.

5. COMBINING DOCUMENTS

You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice.
The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections entitled "History" in the various original documents, forming one section entitled "History"; likewise combine any sections entitled "Acknowledgements", and any sections entitled "Dedications". You must delete all sections entitled "Endorsements."

6. COLLECTIONS OF DOCUMENTS

You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.

7. AGGREGATION WITH INDEPENDENT WORKS

A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, does not as a whole count as a Modified Version of the Document, provided no compilation copyright is claimed for the compilation. Such a compilation is called an "aggregate", and this License does not apply to the other self-contained works thus compiled with the Document, on account of their being thus compiled, if they are not themselves derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one quarter of the entire aggregate, the Document's Cover Texts may be placed on covers that surround only the Document within the aggregate. Otherwise they must appear on covers around the whole aggregate.

8. TRANSLATION

Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License provided that you also include the original English version of this License. In case of a disagreement between the translation and the original English version of this License, the original English version will prevail.

9. TERMINATION

You may not copy, modify, sublicense, or distribute the Document except as expressly provided for under this License. Any other attempt to copy, modify, sublicense or distribute the Document is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.

10. FUTURE REVISIONS OF THIS LICENSE

The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See http://www.gnu.org/copyleft/.
Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License "or any later version" applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation.

How to use this License for your documents

To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page:
Copyright (c) YEAR YOUR NAME. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with the Invariant Sections being LIST THEIR TITLES, with the Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. A copy of the license is included in the section entitled "GNU Free Documentation License".
If you have no Invariant Sections, write "with no Invariant Sections" instead of saying which ones are invariant. If you have no Front-Cover Texts, write "no Front-Cover Texts" instead of "Front-Cover Texts being LIST"; likewise for Back-Cover Texts.
If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.

About this document:

History: Title: The GNU Privacy Handbook - Year: 1999 - Author: Mike Ashley - Publisher: The Free Software Foundation
Title: D&C LUG, Starting with GnuPG FAQ - Year: 2003 - Author: Neil Williams - Publisher: Neil Williams.
Acknowledgements: Adapted from The GNU Privacy Handbook : http://www.gnupg.org/gph/en/manual.html#INTRO
Contributors to this manual include Matthew Copeland, Joergen Grahn, and David A. Wheeler. J Horacio MG has translated the manual to Spanish.
Valid HTML 4.01!
Top