SSH public and private key setup for windows, putty, puttygen and pageant
First setup your primary server’s private keys (*nix).
- Log on to the server, ‘su’ to the desired user (e.g, user1).
- Type ‘ssh-keygen –t dsa’ (without the quotes)
- Add your secret passphrase when prompted. It should generate a .ssh directory in your home folder with two files, ‘id_dsa’ and ‘id_dsa.pub’.
For Windows. Download PuTTY, PuTTYgen and Pageant from:
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
- Create a ssh directory in C (e.g, C:\ssh)
- Execute the PUTTYGEN.EXE program.
- Select the desired key type, "SSH2 DSA", within the "Parameters" section.
- Click on the "Generate" button.
- Follow the instruction to move the mouse over the blank area of the program in order to create random data used by PUTTYGEN to generate secure keys. Key generation will occur once PUTTYGEN has collected sufficient random data.
- If required (maybe because the servername is not in DNS) add it to your hosts file
- Enter username@servername for the key comment, depending on what host the key is for, replacing username with your system username and servername with the name of the server you are connecting to.
- Enter the desired passphrase in the "Key passphrase" and "Confirm passphrase" fields. If the key will be used for automation of operations (i.e. as part of a script), you may choose to omit this step from the key generation process.
- Click on the "Save private key" button. Use the resulting dialog to save your private key data for future use. You may use a filename such as servername.ppk. The .ppk extension is used for PuTTY Private Key files. Save it to C:\ssh. Don’t shut down PuTTYgen yet.
- Save the public key as well if desired.
- Back on the *nix server, make sure you are in the .ssh folder and create the file ‘authorized_keys2’.
- From PuTTYgen, copy the information from the box labelled ‘Public key for pasting into OpenSSH authorized_keys file’ and paste it into the new authorized_keys2 file on the server (making sure there is only the one line and no additional spaces at the end of the line).
- Save the amended file on the server.
- Run Pageant (sits in your system tray), right click the icon and go to ‘Add Keys’.
- Add the id_dsa.pkk key which will be stored in memory via pageant.
- Open up PuTTY, add or load the server details and go to SSH -> Auth in the settings. In the private key for authentication box browse to the ‘id_dsa.ppk’ file on your machine. SAVE the settings and then log onto the server.
- Open up PuTTY, choose the server and it will automatically log you in (the first time may require authentication but it wont after that).


