########################################################################### # GnuPG Notes # # Anuradha Weeraman, 03 June 2004 # # $Id: gnupg.txt,v 1.1 2004/06/02 21:17:53 anuradha Exp $ # ########################################################################### First check if the sources are clean using a trusted version of gpg. gpg --verify gnupg-x.y.z.tar.gz.asc This checks that the detached signature gnupg-x.y.z.tar.gz.asc is indeed a a signature of gnupg-x.y.z.tar.gz. The key used to create this signature is: "pub 1024D/57548DCD 1998-07-07 Werner Koch (gnupg sig) " If you do not have this key, you can get it from the source in the file g10/pubring.asc (use "gpg --import g10/pubring.gpg" to add it to the keyring) or from any keyserver. You have to make sure that this is really the key and not a faked one. You can do this by comparing the output of: $ gpg --fingerprint 0x57548DCD with the elsewhere published fingerprint, or - if you are able to _positively_ verify the signature of this README file - with this fingerprint: "6BD9 050F D8FC 941B 4341 2DCC 68B7 AB89 5754 8DCD" or : $ md5sum gnupg-x.y.z.tar.gz This should yield an output similar_to this: fd9351b26b3189c1d577f0970f9dcadc gnupg-x.y.z.tar.gz Now check that this checksum is _exactly_ the same as the one published via the announcement list and probably via Usenet. 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. Next, you should create a revocation certificate in case someone gets knowledge of your secret key or you forgot your passphrase gpg --gen-revoke your_user_id Now you can use your key to create digital signatures gpg -s file This creates a file "file.gpg" which is compressed and has a signature attached. gpg -sa file Same as above, but creates a file "file.asc" which is ASCII armored and and ready for sending by mail. gpg -s -o out file Creates a signature of "file", but writes the output to the file "out". Everyone who knows your public key (you can and should publish your key by putting it on a key server, a web page or in your .plan file) is now able to check whether you really signed this text gpg --verify file gpg can also run as a filter, so that you can pipe data to verify through it cat signed-file | gpg | wc -l which will check the signature of signed-file and then display the number of lines in the original file. To send a message encrypted to someone you can use gpg -e -r heine file This encrypts "file" with the public key of the user "heine" and writes it to "file.gpg" echo "hello" | gpg -ea -r heine | mail heine Ditto, but encrypts "hello\n" and mails it as ASCII armored message to the user with the mail address heine. gpg -se -r heine file This encrypts "file" with the public key of "heine" and writes it to "file.gpg" after signing it with your user id. gpg -se -r heine -u Suttner file Ditto, but sign the file with your alternative user id "Suttner" GnuPG has some options to help you publish public keys. This is called "exporting" a key, thus gpg --export >all-my-keys To mail a public key or put it on a web page you have to create the key in ASCII armored format gpg --export --armor | mail panther@tiger.int If you have received a key from someone else you can put it into your public keyring. This is called "importing" gpg --import [filenames] New keys are appended to your keyring and already existing keys are updated. Note that GnuPG does not import keys that are not self-signed. Because anyone can claim that a public key belongs to her we must have some way to check that a public key really belongs to the owner. This can be achieved by comparing the key during a phone call. Sure, it is not very easy to compare a binary file by reading the complete hex dump of the file - GnuPG (and nearly every other program used for management of cryptographic keys) provides other solutions. gpg --fingerprint prints the so called "fingerprint" of the given username which is a sequence of hex bytes (which you may have noticed in mail sigs or on business cards) that uniquely identifies the public key - different keys will always have different fingerprints. It is easy to compare fingerprints by phone and I suggest that you print your fingerprint on the back of your business card. To see the fingerprints of the secondary keys, you can give the command twice; but this is normally not needed. If you don't know the owner of the public key you are in trouble. Suppose however that friend of yours knows someone who knows someone who has met the owner of the public key at some computer conference. Suppose that all the people between you and the public key holder may now act as introducers to you. Introducers signing keys thereby certify that they know the owner of the keys they sign. If you then trust all the introducers to have correctly signed other keys, you can be be sure that the other key really belongs to the one who claims to own it.. Okay, here is how GnuPG helps you with key management. Most stuff is done with the --edit-key command gpg --edit-key GnuPG displays some information about the key and then prompts for a command (enter "help" to see a list of commands and see the man page for a more detailed explanation). To sign a key you select the user ID you want to sign by entering the number that is displayed in the leftmost column (or do nothing if the key has only one user ID) and then enter the command "sign" and follow all the prompts. When you are ready, give the command "save" (or use "quit" to cancel your actions). If you want to sign the key with another of your user IDs, you must give an "-u" option on the command line together with the "--edit-key".