signature created using your private key cannot be forged by anybody who does not have that key; but anybody who has your public key can verify that a particular signature is genuine.
So you generate a key pair on your own computer, and you copy the public key to the server. Then, when the server asks you to prove who you are, PuTTY can generate a signature using your private key. The server can verify that signature (since it has your public key) and allow you to log in. Now if the server is hacked or spoofed, the attacker does not gain your private key or password; they only gain one signature. And signatures cannot be re-used, so they have gained nothing.
There is a problem with this: if your private key is stored unprotected on your own computer, then anybody who gains access to that will be able to generate signatures as if they were you. So they will be able to log in to your server under your account. For this reason, your private key is usually encrypted when it is stored on your local machine, using a passphrase of your choice. In order to generate a signature, PuTTY must decrypt the key, so you have to type your passphrase.
This can make public-key authentication less convenient than password authentication: every time you log in to the server, instead of typing a short password, you have to type a longer passphrase. One solution to this is to use an authentication agent, a separate program which holds decrypted private keys and generates signatures on request. PuTTY's authentication agent is called Pageant. When you begin a Windows session, you start Pageant and load your private key into it (typing your passphrase once). For the rest of your session, you can start PuTTY any number of times and Pageant will automatically generate signatures without you having to do anything. When you close your Windows session, Pageant shuts down, without ever having stored your decrypted private key on disk. Many people feel this is a good compromise between security and convenience. See
chapter 9
for further details.
There is more than one public-key algorithm available. The most common is RSA, but others exist, notably DSA (otherwise known as DSS), the USA's federal Digital Signature Standard. The key types supported by PuTTY are described in
section 8.2.2
.
8.2 Using PuTTYgen, the PuTTY key generator
PuTTYgen is a key generator. It generates pairs of public and private keys to be used with PuTTY, PSCP, and Plink, as well as the PuTTY authentication agent, Pageant (see
chapter 9
). PuTTYgen generates RSA and DSA keys.
When you run PuTTYgen you will see a window where you have two choices: ‘Generate’, to generate a new public/private key pair, or ‘Load’ to load in an existing private key.
•
8.2.1 Generating a new key
•
8.2.2 Selecting the type of key
•
8.2.3 Selecting the size (strength) of the key
•
8.2.4 The ‘Generate’ button
•
8.2.5 The ‘Key fingerprint’ box
•
8.2.6 Setting a comment for your key
•
8.2.7 Setting a passphrase for your key
•
8.2.8 Saving your private key to a disk file
•
8.2.9 Saving your public key to a disk file
•
8.2.10 ‘Public key for pasting into authorized_keys file’
•
8.2.11 Reloading a private key
•
8.2.12 Dealing with private keys in other formats
8.2.1 Generating a new key
This is a general outline of the procedure for generating a new key pair. The following sections describe the process in more detail.
•First, you need to select which type of key you want to generate, and also select the strength of the key. This is described in more detail in
section 8.2.2
and
section 8.2.3
.
•Then press the ‘Generate’ button, to actually generate the key.
Section 8.2.4
describes this step.
•Once you have generated the key, select a comment field (
section 8.2.6
) and a passphrase (
section 8.2.7
).
•Now you're ready to save the private key to disk; press the ‘Save private key’ button. (See
section 8.2.8
).
Your key pair is now ready for use. You may also want to copy the public key to your server, either by copying it out of the ‘Public key for pasting into authorized_keys file’ box (see
section 8.2.10
), or by using the ‘Save public key’ button (
section 8.2.9
).
However, you don't need to do this immediately; if you want, you can load the private key back into PuTTYgen later (see
section
8.2.11
) and the public key will be available for copying and pasting again.