1 GNU Privacy Guard -- Frequently Asked Questions
2 =================================================
4 This FAQ is partly compiled from messages of the developers mailing list.
6 Many thanks to Kirk Fort, Brian Warner, ...
9 Q: How does this whole thing work?
10 A: To generate a secret/public keypair, run
14 and choose the default values.
16 Data that is encrypted with a public key can only be decrypted by the
17 matching secret key. The secret key is protected by a password, the
20 So to send your friend a message, you would encrypt your message with his
21 public key, and he would only be able to decrypt it by having the secret
22 key and putting in the password to use his secret key.
24 GnuPG is also useful for signing things. Things that are encrypted with
25 the secret key can be decrypted with the public key. To sign something, a
26 hash is taken of the data, and then the hash is in some form encoded with
27 the secret key. If someone has your public key, they can verify that it
28 is from you and that it hasn't changed by checking the encoded form of
29 the hash with the public key.
31 A keyring is just a large file that stores keys. You have a public keyring
32 where you store yours and your friend's public keys. You have a secret
33 keyring that you keep your secret key on, and be very careful with this
34 secret keyring: Never ever give anyone else access to it and use a *good*
35 passphrase to protect the data in it.
37 You can 'conventionally' encrypt something by using the option 'gpg -c'.
38 It is encrypted using a passphrase, and does not use public and secret
39 keys. If the person you send the data to knows that passphrase, they can
40 decrypt it. This is usually most useful for encrypting things to
41 yourself, although you can encrypt things to your own public key in the
42 same way. It should be used for communication with partners you know and
43 where it is easy to exchange the passphrases (e.g. with your boy friend or
44 your wife). The advantage is that you can change the passphrase from time
45 to time and decrease the risk, that many old messages may be decrypted by
46 people who accidently got your passphrase.
48 You can add and copy keys to and from your keyring with the 'gpg --import'
49 and 'gpg --export' option. 'gpg --export-secret-keys' will export secret
50 keys. This is normally not useful, but you can generate the key on one
51 machine then move it to another machine.
53 Keys can be signed under the 'gpg --edit-key' option. When you sign a
54 key, you are saying that you are certain that the key belongs to the
55 person it says it comes from. You should be very sure that is really
56 that person: You should verify the key fingerprint
58 gpg --fingerprint user-id
60 over phone (if you really know the voice of the other person) or at
61 a key signing party (which are often held at computer conferences)
62 or at a meeting of your local GNU/Linux User Group.
64 Hmm, what else. You may use the option "-o filename" to force output
65 to this filename (use "-" to force output to stdout). "-r" just lets you
66 specify the recipient (which public key you encrypt with) on the command
67 line instead of typing it interactively.
69 Oh yeah, this is important. By default all data is encrypted in some weird
70 binary format. If you want to have things appear in ASCII text that is
71 readable, just add the '-a' option. But the preferred method is to use
72 a MIME aware mail reader (Mutt, Pine and many more).
74 There is a small security glitch in the OpenPGP (and therefore GnuPG) system;
75 to avoid this you should always sign and encrypt a message instead of only
79 Q: What is the recommended key size?
80 A: 1024 bit for DSA signatures; even for plain ElGamal
81 signatures this is sufficient as the size of the hash
82 is probably the weakest link if the keysize is larger
83 than 1024 bits. Encryption keys may have greater sizes,
84 but you should than check the fingerprint of this key:
85 "gpg --fingerprint --fingerprint <user ID>".
87 Q: Why are some signatures with an ELG-E key valid?
88 A: These are ElGamal Key generated by GnuPG in v3 (rfc1991)
89 packets. The OpenPGP draft later changed the algorithm
90 identifier for ElGamal keys which are usable for signatures
91 and encryption from 16 to 20. GnuPG now uses 20 when it
92 generates new ElGamal keys but still accept 16 (which is
93 according to OpenPGP "encryption only") if this key is in
94 a v3 packet. GnuPG is the only program which had used
95 these v3 ElGamal keys - so this assumption is quite safe.
97 Q: Why is PGP 5.x not able to encrypt messages with some keys?
98 A: PGP Inc refuses to accept ElGamal keys of type 20 even for
99 encryption. They only support type 16 (which is identical
100 at least for decryption). To be more inter-operable, GnuPG
101 (starting with version 0.3.3) now also uses type 16 for the
102 ElGamal subkey which is created if the default key algorithm
103 is chosen. You may add an type 16 ElGamal key to your public
104 key which is easy as your key signatures are still valid.
106 Q: Why is PGP 5.x not able to verify my messages?
107 A: PGP 5.x does not accept V4 signatures for data material but
108 OpenPGP requires generation of V4 signatures for all kind of
109 data. Use the option "--force-v3-sigs" to generate V3 signatures
112 Q: I can't delete an user id because it is already deleted on my
114 A: Because you can only select from the public key ring, there is
115 no direct way to do this. However it is not very complicated
116 to do it anyway. Create a new user id with exactly the same name
117 and you will see that there are now two identical user ids on the
118 secret ring. Now select this user id and delete it. Both user
119 ids will be removed from the secret ring.
121 Q: How can I encrypt a message so that pgp 2.x is able to decrypt it?
122 A: You can't do that because pgp 2.x normally uses IDEA which is not
123 supported by GnuPG because it is patented, but if you have a modified
124 version of PGP you can try this:
126 gpg --rfc1991 --cipher-algo 3des ...
128 Please don't pipe the data to encrypt to gpg but give it as a filename;
129 other wise, pgp 2 will not be able to handle it.
131 Q: How can I conventional encrypt a message, so that PGP can decrypt it?
132 A: You can't do this for PGP 2. For PGP 5 you should use this:
134 gpg -c --cipher-algo 3des --compress-algo 1 myfile
136 You may replace "3des" by "cast5". "blowfish" does not work with
137 all versions of pgp5. You may also want to put
139 into your ~/.gnupg/options file - this does not affect normal
143 Q: Why does it sometimes take so long to create keys?
144 A: The problem here is that we need a lot of random bytes and for that
145 we (on Linux the /dev/random device) must collect some random data.
146 It is really not easy to fill the Linux internal entropy buffer; I
147 talked to Ted Ts'o and he commented that the best way to fill the buffer
148 is to play with your keyboard. Good security has it's price. What I do
149 is to hit several times on the shift, control, alternate, and capslock
150 keys, because these keys do not produce output to the screen. This way
151 you get your keys really fast (it's the same thing pgp2 does).
153 Another problem might be another program which eats up your random bytes
154 (a program (look at your daemons) that reads from /dev/[u]random).
156 Q: And it really takes long when I work on a remote system. Why?
157 A: Don't do this at all! You should never create keys or even use GnuPG
158 on a remote system because you normally have no physical control over
159 your secret keyring (which is in most cases vulnerable to advanced
160 dictionary attacks) - I strongly encourage everyone to only create keys
161 on a local computer (a disconnected laptop is probably the best choice)
162 and if you need it on your connected box (I know: We all do this) be
163 sure to have a strong password for your account and for your secret key
164 and that you can trust your system administrator.
166 When I check GnuPG on a remote system via ssh (I have no Alpha here ;-)
167 I have the same problem. It takes a *very* long time to create the
168 keys, so I use a special option, --quick-random, to generate insecure
169 keys which are only good for some tests.
172 Q: How does the whole trust thing work?
173 A: It works more or less like PGP. The difference is that the trust is
174 computed at the time it is needed. This is one of the reasons for the
175 trustdb which holds a list of valid key signatures. If you are not
176 running in batch mode you will be asked to assign a trust parameter
177 (ownertrust) to a key.
179 You can see the validity (calculated trust value) using this command.
181 gpg --list-keys --with-colons
183 If the first field is "pub" or "uid", the second field shows you the trust:
185 o = Unknown (this key is new to the system)
186 e = The key has expired
187 q = Undefined (no value assigned)
188 n = Don't trust this key at all
189 m = There is marginal trust in this key
190 f = The key is full trusted.
191 u = The key is ultimately trusted; this
192 is only used for keys for which
193 the secret key is also available.
194 r = The key has been revoked
195 d = The key has been disabled
197 The value in the "pub" record is the best one of all "uid" records.
199 You can get a list of the assigned trust values (how much you trust
200 the owner to correctly sign another person's key)
202 gpg --list-ownertrust
204 The first field is the fingerprint of the primary key, the second field
205 is the assigned value:
207 - = No Ownertrust value yet assigned.
208 n = Never trust this keyholder to correctly verify others signatures.
209 m = Have marginal trust in the keyholders capability to sign other keys.
210 f = Assume that the key holder really knows how to sign keys.
211 u = No need to trust ourself because we have the secret key.
213 Keep these values confidential because they express your opinions
214 about others. PGP stores this information with the keyring thus
215 it is not a good idea to publish a PGP keyring instead of exporting the
216 keyring. gnupg stores the trust in the trust-DB so it is okay
217 to give a gpg keyring away (but we have a --export command too).
220 Q: What is the difference between options and commands?
221 A: If you do a "gpg --help", you will get two separate lists. The first is
222 a list of commands. The second is a list of options. Whenever you run GPG,
223 you *must* pick exactly one command (**with one exception, see below). You
224 *may* pick one or more options. The command should, just by convention,
225 come at the end of the argument list, after all the options. If the
226 command takes a file (all the basic ones do), the filename comes at the
227 very end. So the basic way to run gpg is:
229 gpg [--option something] [--option2] [--option3 something] --command file
231 Some options take arguments, for example the --output option (which can be
232 abbreviated -o) is an option that takes a filename. The option's argument
233 must follow immediately after the option itself, otherwise gpg doesn't know
234 which option the argument is supposed to go with. As an option, --output and
235 its filename must come before the command. The --remote-user (-r) option takes
236 a name or keyid to encrypt the message to, which must come right after the -r
237 argument. The --encrypt (or -e) command comes after all the options followed
238 by the file you wish to encrypt. So use
240 gpg -r alice -o secret.txt -e test.txt
242 If you write the options out in full, it is easier to read
244 gpg --remote-user alice --output secret.txt --encrypt test.txt
246 If you're saving it in a file called ".txt" then you'd probably expect to see
247 ASCII-armored text in there, so you need to add the --armor (-a) option,
248 which doesn't take any arguments.
250 gpg --armor --remote-user alice --output secret.txt --encrypt test.txt
252 If you imagine square brackets around the optional parts, it becomes a bit
255 gpg [--armor] [--remote-user alice] [--output secret.txt] --encrypt test.txt
257 The optional parts can be rearranged any way you want.
259 gpg --output secret.txt --remote-user alice --armor --encrypt test.txt
261 If your filename begins with a hyphen (e.g. "-a.txt"), gnupg assumes this is
262 an option and may complain. To avoid this you have either to use
263 "./-a.txt" or stop the option and command processing with two hyphens:
266 ** the exception: signing and encrypting at the same time. Use
268 gpg [--options] --sign --encrypt foo.txt
271 Q: What kind of output is this: "key C26EE891.298, uid 09FB: ...."?
272 A: This is the internal representation of an user id in the trustdb.
273 "C26EE891" is the keyid, "298" is the local id (a record number
274 in the trustdb) and "09FB" is the last two bytes of a ripe-md-160
275 hash of the user id for this key.
278 Q: What is trust, validity and ownertrust?
279 A: "ownertrust" is used instead of "trust" to make clear that
280 this is the value you have assigned to a key to express how much you
281 trust the owner of this key to correctly sign (and so introduce)
282 other keys. "validity", or calculated trust, is a value which
283 says how much GnuPG thinks a key is valid (that it really belongs
284 to the one who claims to be the owner of the key).
285 For more see the chapter "The Web of Trust" in the
286 Manual [gpg: Oops: Internal error: manual not found - sorry]
288 Q: How do I interpret some of the informational outputs?
289 A: While checking the validity of a key, GnuPG sometimes prints
290 some information which is prefixed with information about
293 This is about the key with key ID 12345678 and the internal
294 number 3456, which is the record number of the so called
295 directory record in the trustdb.
296 "uid 12345678.3456/ACDE"
297 This is about the user ID for the same key. To identify the
298 user ID the last two bytes of a ripe-md-160 over the user ID
300 "sig 12345678.3456/ACDE/9A8B7C6D"
301 This is about the signature with key ID 9A8B7C6D for the
302 above key and user ID, if it is a signature which is direct
303 on a key, the user ID part is empty (..//..).
306 Q: How do I sign a patch file?
307 A: Use "gpg --clearsign --not-dash-escaped ...".
308 The problem with --clearsign is that all lines starting with a dash are
309 quoted with "- "; obviously diff produces many of lines starting with a
310 dash and these are then quoted and that is not good for patch ;-). To
311 use a patch file without removing the cleartext signature, the special
312 option --not-dash-escaped may be used to suppress generation of these
313 escape sequences. You should not mail such a patch because spaces and
314 line endings are also subject to the signature and a mailer may not
315 preserve these. If you want to mail a file you can simply sign it
319 Q: Where is the "encrypt-to-self" option?
320 A: Use "--encrypt-to your_keyid". You can use more than one
321 of these options. To temporary override the use of this additional
322 keys, you can use the option "--no-encrypt-to".
325 Q: How can I get rid of the Version and Comment headers in
327 A: Use "--no-version --comment ''". Note that the left over blank line
328 is required by the protocol.
331 Q: What does the "You are using the xxxx character set." mean?
332 A: This note is printed when UTF8 mapping has to be done. Make sure that
333 the displayed charset is the one you have activated on your system
334 "iso-8859-1" is the most used one, so this is the default. You can
335 change the charset with the option "--charset". It is important that
336 you active character set matches the one displayed - if not, restrict
337 yourself to plain 7 bit ASCII and no mapping has to be done.
339 Q: How do I transfer owner trust values from PGP to GnuPG?
340 A: There is a script in the tools directory to help you:
341 After you have imported the PGP keyring you can give this command:
342 $ lspgpot pgpkeyring | gpg --import-ownertrust