Updated the PuTTYgen section in pubkey.but so that it gives
[sgt/putty] / doc / pubkey.but
CommitLineData
0906628e 1\versionid $Id: pubkey.but,v 1.12 2001/12/12 18:45:56 simon Exp $
024f5783 2
e5b0d077 3\C{pubkey} Using public keys for SSH authentication
4
024f5783 5\H{pubkey-intro} Public key authentication - an introduction
6
388f343b 7Public key authentication is an alternative means of identifying
8yourself to a login server, instead of typing a password. It is more
9secure and more flexible, but more difficult to set up.
10
11In conventional password authentication, you prove you are who you
12claim to be by proving that you know the correct password. The only
13way to prove you know the password is to tell the server what you
14think the password is. This means that if the server has been
15hacked, or \e{spoofed} (see \k{gs-hostkey}), an attacker can learn
16your password.
17
18Public key authentication solves this problem. You generate a \e{key
19pair}, consisting of a public key (which everybody is allowed to
20know) and a private key (which you keep secret and do not give to
21anybody). The private key is able to generate \e{signatures}.
2f8d6d43 22A signature created using your private key cannot be forged by
388f343b 23anybody who does not have that key; but anybody who has your public
24key can verify that a particular signature is genuine.
25
26So you generate a key pair on your own computer, and you copy the
27public key to the server. Then, when the server asks you to prove
2f8d6d43 28who you are, PuTTY can generate a signature using your private key.
388f343b 29The server can verify that signature (since it has your public key)
30and allow you to log in. Now if the server is hacked or spoofed, the
31attacker does not gain your private key or password; they only gain
32one signature. And signatures cannot be re-used, so they have gained
33nothing.
34
35There is a problem with this: if your private key is stored
36unprotected on your own computer, then anybody who gains access to
37\e{that} will be able to generate signatures as if they were you. So
38they will be able to log in to your server under your account. For
39this reason, your private key is usually \e{encrypted} when it is
40stored on your local machine, using a passphrase of your choice. In
41order to generate a signature, PuTTY must decrypt the key, so you
42have to type your passphrase.
43
44This can make public-key authentication less convenient than
45password authentication: every time you log in to the server,
46instead of typing a short password, you have to type a longer
47passphrase. One solution to this is to use an \e{authentication
48agent}, a separate program which holds decrypted private keys and
49generates signatures on request. PuTTY's authentication agent is
50called Pageant. When you begin a Windows session, you start Pageant
51and load your public key into it (typing your passphrase once). For
2f8d6d43 52the rest of your session, you can start PuTTY any number of times
388f343b 53and Pageant will automatically generate signatures without you
54having to do anything. When you close your Windows session, Pageant
55shuts down, without ever having stored your decrypted private key on
56disk. Many people feel this is a good compromise between security
57and convenience. See \k{pageant} for further details.
e5b0d077 58
0906628e 59There is more than one public-key algorithm available. The most
60common is RSA, but others exist, notably DSA (otherwise known as
61DSS), the USA's federal Digital Signature Standard. The key types
62supported by PuTTY are described in \k{puttygen-keytype}.
63
64\H{pubkey-puttygen} Using PuTTYgen, the PuTTY key generator
65
66PuTTYgen is a key generator. It generates pairs of public and private
67keys to be used with PuTTY, PSCP, and Plink, as well as the PuTTY
68authentication agent, Pageant (see \k{pageant}). PuTTYgen generates
69RSA keys.
70
71When you run PuTTYgen you will see a window where you have two
72choices: \q{Generate}, to generate a new public/private key pair, or
73\q{Load} to load in an existing private key.
74
75\S{puttygen-generating} Generating a new key
76
77This is a general outline of the procedure for generating a new key
78pair. The following sections describe the process in more detail.
79
80\b First, you need to select which type of key you want to generate,
81and also select the strength of the key. This is described in more
82detail in \k{puttygen-keytype} and
83\k{puttygen-strength}.
84
85\b Then press the \q{Generate} button, to actually generate the key.
86\K{puttygen-generate} describes this step.
87
88\b Once you have generated the key, select a comment field
89(\k{puttygen-comment}) and a passphrase (\k{puttygen-passphrase}).
90
91\b Now you're ready to save the private key to disk; press the
92\q{Save private key} button. (See \k{puttygen-savepriv}).
93
94Your key pair is now ready for use. You may also want to copy the
95public key to your server, either by copying it out of the \q{Public
96key for pasting into authorized_keys file} box (see
97\k{puttygen-pastekey}), or by using the \q{Save public key} button
98(\k{puttygen-savepub}). However, you don't need to do this
99immediately; if you want, you can load the private key back into
100PuTTYgen later (see \k{puttygen-load}) and the public key will be
101available for copying and pasting again.
5c72ca61 102
0906628e 103\k{pubkey-gettingready} describes the typical process of configuring
104PuTTY to attempt public-key authentication, and configuring your SSH
105server to accept it.
106
107\S{puttygen-keytype} Selecting the type of key
108
109\cfg{winhelp-topic}{puttygen.keytype}
110
111Before generating a public key using PuTTYgen, you need to select
112which type of key you need. PuTTYgen currently supports three types
113of key:
5c72ca61 114
115\b An RSA key for use with the SSH 1 protocol.
9e55cd45 116
5c72ca61 117\b An RSA key for use with the SSH 2 protocol.
9e55cd45 118
5c72ca61 119\b A DSA key for use with the SSH 2 protocol.
120
121The SSH 1 protocol only supports RSA keys; if you will be connecting
122using the SSH 1 protocol, you must select the first key type or your
123key will be completely useless.
124
0906628e 125The SSH 2 protocol supports more than one key type. The two types
126supported by PuTTY are RSA and DSA.
5c72ca61 127
128The PuTTY developers \e{strongly} recommend you use RSA. DSA has an
129intrinsic weakness which makes it very easy to create a signature
130which contains enough information to give away the \e{private} key!
131This would allow an attacker to pretend to be you for any number of
132future sessions. PuTTY's implementation has taken very careful
133precautions to avoid this weakness, but we cannot be 100% certain we
134have managed it, and if you have the choice we strongly recommend
135using RSA keys instead.
136
137If you really need to connect to an SSH server which only supports
138DSA, then you probably have no choice but to use DSA. If you do use
139DSA, we recommend you do not use the same key to authenticate with
140more than one server.
141
0906628e 142\S{puttygen-strength} Selecting the size (strength) of the key
024f5783 143
0906628e 144\cfg{winhelp-topic}{puttygen.bits}
024f5783 145
0906628e 146The \q{Number of bits} input box allows you to choose the strength
147of the key PuTTYgen will generate.
148
149Currently 1024 bits should be sufficient for most purposes.
150
151\S{puttygen-generate} The \q{Generate} button
152
153\cfg{winhelp-topic}{puttygen.generate}
154
155Once you have chosen the type of key you want, and the strength of
156the key, press the \q{Generate} button and PuTTYgen will begin the
157process of actually generating the key.
158
159First, a progress bar will appear and PuTTYgen will ask you to move
160the mouse around to generate randomness. Wave the mouse in circles
161over the blank area in the PuTTYgen window, and the progress bar
162will gradually fill up as PuTTYgen collects enough randomness. You
163don't need to wave the mouse in particularly imaginative patterns
164(although it can't hurt); PuTTYgen will collect enough randomness
165just from the fine detail of \e{exactly} how far the mouse has moved
166each time Windows samples its position.
167
168When the progress bar reaches the end, PuTTYgen will begin creating
169the key. The progress bar will reset to the start, and gradually
170move up again to track the progress of the key generation. It will
171not move evenly, and may occasionally slow down to a stop; this is
172unfortunately unavoidable, because key generation is a random
173process and it is impossible to reliably predict how long it will
174take.
175
176When the key generation is complete, a new set of controls will
177appear in the window to indicate this.
178
179\S{puttygen-fingerprint} The \q{Key fingerprint} box
024f5783 180
0906628e 181\cfg{winhelp-topic}{puttygen.fingerprint}
182
183The \q{Key fingerprint} box shows you a fingerprint value for the
184generated key. This is derived cryptographically from the \e{public}
185key value, so it doesn't need to be kept secret.
186
187The fingerprint value is intended to be cryptographically secure, in
188the sense that it is computationally infeasible for someone to
189invent a second key with the same fingerprint, or to find a key with
190a particular fingerprint. So some utilities, such as the Pageant key
191list box (see \k{pageant-mainwin-keylist}) and the Unix \c{ssh-add}
192utility, will list key fingerprints rather than the whole public key.
193
194\S{puttygen-comment} Setting a comment for your key
195
196\cfg{winhelp-topic}{puttygen.comment}
197
198If you have more than one key and use them for different purposes,
199you don't need to memorise the key fingerprints in order to tell
200them apart. PuTTY allows you to enter a \e{comment} for your key,
201which will be displayed whenever PuTTY or Pageant asks you for the
202passphrase.
203
204The default comment format, if you don't specify one, contains the
205key type and the date of generation, such as \c{rsa-key-20011212}.
206Another commonly used approach is to use your name and the name of
207the computer the key will be used on, such as \c{simon@simons-pc}.
208
209To alter the key comment, just type your comment text into the
210\q{Key comment} box before saving the private key. If you want to
211change the comment later, you can load the private key back into
212PuTTYgen, change the comment, and save it again.
213
214\S{puttygen-passphrase} Setting a passphrase for your key
215
216\cfg{winhelp-topic}{puttygen.passphrase}
217
218The \q{Key passphrase} and \q{Confirm passphrase} boxes allow you to
219choose a passphrase for your key. The passphrase will be used to
220encrypt the key on disk, so you will not be able to use the key
221without first entering the passphrase.
222
223When you save the key, PuTTY will check that the \q{Key passphrase}
224and \q{Confirm passphrase} boxes both contain exactly the same
225passphrase, and will refuse to save the key otherwise.
226
227If you leave the passphrase fields blank, the key will be saved
228unencrypted. You should \e{not} do this without good reason; if you
229do, your private key file on disk will be all an attacker needs to
230gain access to any machine configured to accept that key. If you
231want to be able to log in without having to type a passphrase every
232time, you should consider using Pageant (\k{pageant}) so that your
233decrypted key is only held in memory rather than on disk.
234
235Under special circumstances you may genuinely \e{need} to use a key
236with no passphrase; for example, if you need to run an automated
237batch script that needs to make an SSH connection, you can't be
238there to type the passphrase. In this case we recommend you generate
239a special key for each specific batch script (or whatever) that
240needs one, and on the server side you should arrange that each key
241is \e{restricted} so that it can only be used for that specific
242purpose. The documentation for your SSH server should explain how to
243do this (it will probably vary between servers).
244
245Choosing a good passphrase is difficult. Just as you shouldn't use a
246dictionary word as a password because it's easy for an attacker to
8f1529bc 247run through a whole dictionary, you should not use a song lyric,
248quotation or other well-known sentence as a passphrase. DiceWare
eb92e68f 249(\W{http://www.diceware.com/}\cw{www.diceware.com}) recommends using
250at least five words each generated randomly by rolling five dice,
65befd9c 251which gives over 2^64 possible passphrases and is probably not a bad
eb92e68f 252scheme. If you want your passphrase to make grammatical sense, this
253cuts down the possibilities a lot and you should use a longer one as
0906628e 254a result.
255
256\e{Do not forget your passphrase}. There is no way to recover it.
257
258\S{puttygen-savepriv} Saving your private key to a disk file
259
260\cfg{winhelp-topic}{puttygen.savepriv}
261
262Once you have generated a key, set a comment field and set a
263passphrase, you are ready to save your private key to disk.
264
265Press the \q{Save private key} button. PuTTYgen will put up a dialog
266box asking you where to save the file. Select a directory, type in a
267file name, and press \q{Save}.
024f5783 268
0906628e 269This file is the one you will need to tell PuTTY to use for
270authentication (see \k{config-ssh-privkey}) or tell Pageant to load
271(see \k{pageant-mainwin-addkey}).
024f5783 272
0906628e 273\S{puttygen-savepub} Saving your public key to a disk file
024f5783 274
0906628e 275\cfg{winhelp-topic}{puttygen.savepub}
024f5783 276
0906628e 277The SSH 2 protocol drafts specify a standard format for storing
278public keys on disk. Some SSH servers (such as \cw{ssh.com}'s)
279require a public key in this format in order to accept
280authentication with the corresponding private key. (Others, such as
281OpenSSH, use a different format; see \k{puttygen-pastekey}.)
282
283To save your public key in the SSH 2 standard format, press the
284\q{Save public key} button in PuTTYgen. PuTTYgen will put up a
285dialog box asking you where to save the file. Select a directory,
286type in a file name, and press \q{Save}.
287
288You will then probably want to copy the public key file to your SSH
289server machine. See \k{pubkey-gettingready} for general instructions
290on configuring public-key authentication once you have generated a
291key.
292
293If you use this option with an SSH 1 key, the file PuTTYgen saves
294will contain exactly the same text that appears in the \q{Public key
295for pasting} box. This is the only existing standard for SSH 1
296public keys.
297
298\S{puttygen-pastekey} \q{Public key for pasting into authorized_keys
299file}
300
301\cfg{winhelp-topic}{puttygen.pastekey}
302
303All SSH 1 servers require your public key to be given to it in a
304one-line format before it will accept authentication with your
305private key. The OpenSSH server also requires this for SSH 2.
306
307The \q{Public key for pasting into authorized_keys file} gives the
308public-key data in the correct one-line format. Typically you will
309want to select the entire contents of the box using the mouse, press
310Ctrl+C to copy it to the clipboard, and then paste the data into a
311PuTTY session which is already connected to the server.
312
313See \k{pubkey-gettingready} for general instructions on configuring
314public-key authentication once you have generated a key.
315
316\S{puttygen-load} Reloading a private key
317
318\cfg{winhelp-topic}{puttygen.load}
319
320PuTTYgen allows you to load an existing private key file into
321memory. If you do this, you can then change the passphrase and
322comment before saving it again; you can also make extra copies of
323the public key.
324
325To load an existing key, press the \q{Load} button. PuTTYgen will
326put up a dialog box where you can browse around the file system and
327find your key file. Once you select the file, PuTTYgen will ask you
328for a passphrase (if necessary) and will then display the key
329details in the same way as if it had just generated the key.
330
331\H{pubkey-gettingready} Getting ready for public key authentication
024f5783 332
333Connect to your SSH server using PuTTY with the SSH protocol. When the
334connection succeeds you will be prompted for your user name and
5c72ca61 335password to login. Once logged in, you must configure the server to
336accept your public key for authentication:
337
338\b If your server is using the SSH 1 protocol, you should change
339into the \c{.ssh} directory and open the file \c{authorized_keys}
340with your favorite editor. (You may have to create this file if this
341is the first key you have put in it). Then switch to the PuTTYgen
d60c975d 342window, select all of the text in the \q{Public key for pasting into
0906628e 343authorized_keys file} box (see \k{puttygen-pastekey}), and copy it
344to the clipboard (\c{Ctrl+C}). Then, switch back to the PuTTY window
345and insert the data into the open file, making sure it ends up all
346on one line. Save the file.
5c72ca61 347
348\b If your server is OpenSSH and is using the SSH 2 protocol, you
0906628e 349should follow the same instructions, except that in earlier versions
350of OpenSSH 2 the file might be called \c{authorized_keys2}. (In
351modern versions the same \c{authorized_keys} file is used for both
352SSH 1 and SSH 2 keys.)
5c72ca61 353
354\b If your server is \cw{ssh.com}'s SSH 2 product, you need to save
0906628e 355a \e{public} key file from PuTTYgen (see \k{puttygen-savepub}), and
356copy that into the \c{.ssh2} directory on the server. Then you
357should go into that \c{.ssh2} directory, and edit (or create) a file
358called \c{authorization}. In this file you should put a line like
359\c{Key mykey.pub}, with \c{mykey.pub} replaced by the name of your
360key file.
5c72ca61 361
362\b For other SSH server software, you should refer to the manual for
363that server.
364
0906628e 365You may also need to ensure that your home directory, your \c{.ssh}
366directory, and any other files involved (such as
367\c{authorized_keys}, \c{authorized_keys2} or \c{authorization}) are
368not group-writable. You can typically do this by using a command
369such as
370
371\c chmod g-w $HOME $HOME/.ssh $HOME/.ssh/authorized_keys
372
373Your server should now be configured to accept authentication using
374your private key. Now you need to configure PuTTY to \e{attempt}
375authentication using your private key. You can do this in either of
376two ways:
377
378\b Select the private key in PuTTY's configuration. See
379\k{config-ssh-privkey} for details.
380
381\b Load the private key into Pageant (see \k{pageant}). In this case
382PuTTY will automatically try to use it for authentication if it can.