6946fa969efccf32ccb63179bb63561aeceebc98
[u/mdw/putty] / doc / pubkey.but
1 \versionid $Id: pubkey.but,v 1.4 2001/09/22 15:36:44 simon Exp $
2
3 \# FIXME: passphrases, examples (e.g what does a key for pasting into
4 \# authorized_keys look like?), index entries, links.
5
6 \C{pubkey} Using public keys for SSH authentication
7
8 \H{pubkey-intro} Public key authentication - an introduction
9
10 Public key authentication is an alternative means of identifying
11 yourself to a login server, instead of typing a password. It is more
12 secure and more flexible, but more difficult to set up.
13
14 In conventional password authentication, you prove you are who you
15 claim to be by proving that you know the correct password. The only
16 way to prove you know the password is to tell the server what you
17 think the password is. This means that if the server has been
18 hacked, or \e{spoofed} (see \k{gs-hostkey}), an attacker can learn
19 your password.
20
21 Public key authentication solves this problem. You generate a \e{key
22 pair}, consisting of a public key (which everybody is allowed to
23 know) and a private key (which you keep secret and do not give to
24 anybody). The private key is able to generate \e{signatures}.
25 A signature created using your private key cannot be forged by
26 anybody who does not have that key; but anybody who has your public
27 key can verify that a particular signature is genuine.
28
29 So you generate a key pair on your own computer, and you copy the
30 public key to the server. Then, when the server asks you to prove
31 who you are, PuTTY can generate a signature using your private key.
32 The server can verify that signature (since it has your public key)
33 and allow you to log in. Now if the server is hacked or spoofed, the
34 attacker does not gain your private key or password; they only gain
35 one signature. And signatures cannot be re-used, so they have gained
36 nothing.
37
38 There is a problem with this: if your private key is stored
39 unprotected on your own computer, then anybody who gains access to
40 \e{that} will be able to generate signatures as if they were you. So
41 they will be able to log in to your server under your account. For
42 this reason, your private key is usually \e{encrypted} when it is
43 stored on your local machine, using a passphrase of your choice. In
44 order to generate a signature, PuTTY must decrypt the key, so you
45 have to type your passphrase.
46
47 This can make public-key authentication less convenient than
48 password authentication: every time you log in to the server,
49 instead of typing a short password, you have to type a longer
50 passphrase. One solution to this is to use an \e{authentication
51 agent}, a separate program which holds decrypted private keys and
52 generates signatures on request. PuTTY's authentication agent is
53 called Pageant. When you begin a Windows session, you start Pageant
54 and load your public key into it (typing your passphrase once). For
55 the rest of your session, you can start PuTTY any number of times
56 and Pageant will automatically generate signatures without you
57 having to do anything. When you close your Windows session, Pageant
58 shuts down, without ever having stored your decrypted private key on
59 disk. Many people feel this is a good compromise between security
60 and convenience. See \k{pageant} for further details.
61
62 \H{pubkey-puttygen} PuTTYgen: RSA key generator for PuTTY
63
64 PuTTYgen is a key generator. It generates pairs of public and private
65 keys to be used with PuTTY, PSCP, and Plink, as well as the PuTTY
66 authentication agent, Pageant (see \k{pageant}). PuTTYgen generates
67 RSA keys.
68
69 When you run PuTTYgen you will see a window where you have two
70 choices: \e{Generate} new public/private key pair or \e{Load} an
71 existing private key.
72
73 \S{pubkey-puttygen-generate} Generate a new key
74
75 Before generating a new key you have to choose the strength of the
76 encryption. With \e{Parameters} you define the strength of the key. The
77 default of 1024 should be OK for most users.
78
79 Pressing the \e{Generate} button starts the process of generating a
80 new key pair. You then have to move the mouse over the blank area in
81 order to generate random data for the algorithm. Continue until the
82 progress bar is complete.
83
84 As soon as enough random data is available the key is generated. This
85 may take a little while, especially on slow machines. Once the key is
86 generated, its details appear in the \e{Key} part of the PuTTYgen
87 window.
88
89 Now you can change the \e{Key comment} to something more meaningful
90 than the default (which is based on the current date). e.g. add the
91 name of the host you will use it for. When using multiple keys a
92 meaningful comment may help you remember which passphrase to use! You
93 should always enter a \e{Key passphrase} and \e{Confirm passphrase} to
94 protect your keys.
95
96 \# FIXME: Mention a good length for a passphrase. (I think Schneier
97 \# said something about this on counterpane.com once.)
98
99 \# In case people don't like the idea of exchanging a short password
100 \# typed every time for a longer passphrase typed every time, link
101 \# to the Pageant chapter.
102
103 Finally save the key by pressing the \e{Save} button. Do not close the
104 window but proceed with step \k{pubkey-gettingready}, otherwise you
105 will have to \e{Load} the private key again as described below.
106
107 \S{pubkey-puttygen-load} Load and modify a key
108
109 PuTTYgen does not store the public key in a file by default. If you
110 have to distribute the public key you can press the \e{Load} button,
111 select the private key file, and PuTTYgen will give you the public key
112 again. You can also change the comment and passphrase for your
113 private key this way. Just modify the values and \e{Save} the key.
114
115 \S{pubkey-gettingready} Getting ready for public key authentication
116
117 Connect to your SSH server using PuTTY with the SSH protocol. When the
118 connection succeeds you will be prompted for your user name and
119 password to login. Once logged in change into the \c{.ssh} directory
120 and open the file \c{authorized_keys} with your favorite editor (you
121 may have to create this file if this is the first key to add).
122
123 Switch to the PuTTYgen window and select all of the content below
124 \e{Public key for pasting into authorized_keys file}, copy it to the
125 clipboard (\c{Ctrl+C}). Then, switch back to the PuTTY window and
126 insert the data into the open file. Save the file.
127
128 From now on you can use the private key for authentication to this
129 host. Either select the private key in PuTTY's \e{Connection},
130 \e{SSH} panel: \e{Private key file for authentication} dialog or use
131 it with Pageant as described in \k{pageant}.