You are here

SSH password-less login using PuTTY on Windows

Submitted by Druss on Thu, 2011-06-30 00:27

So, if you, like me, have to resort to PuTTY sometimes to SSH into a Linux box, I'm sure that you have also subjected yourself to much gnashing of teeth at the lack of a Windows solution to password-less logins into your server. For the uninitiated, password-less SSH allows you to log into a server without manually authenticating yourself. This is taken care of automatically by the program which provides a private key to the server which in turn authenticates it using a public key it already retains. This, while improving ease of use, is also an important security option as you can, ideally, turn off manual authentication once password-less entry is set up (provided you have a way of rescuing yourself if you ever lock yourself out accidentally).

Anyways, enough wibbling. Here's how to set up PuTTY and password-less entry:

  • This guide assumes that we have installed PuTTY using the installer which installs all required programs including putty.exe and puttygen.exe. It also assumes that we already have a working saved session named FOO in PuTTY. which can be used to connect to the server successfully.
  • Run the PuTTY Key Generator/PuTTYgen program from the START menu.
  • In the ensuing window, leave the defaults as they are (1024-bit RSA SSH-2, with empty passphrases) and click on the Generate button.
  • Click the Save public key button and save the key as public.key in a new folder named putty.
  • Click the Save private key button and save the key as private.ppk in the same folder.
  • Also copy the public key in the textarea at the top to the clipboard.
  • Now, SSH into the FOO server and navigate to the ~/.ssh directory where ~ signified the home directory.
  • Create a file here named authorized_keys and paste our copied key into it and save the file.
  • Exit the SSH session.
  • Bring up the default PuTTY session window and load the FOO session.
  • In the Category listing on the left hand side of the dialog, choose Connection and under it, Data.
  • In the resulting window, under Login details, add the username in the Auto-login username textfield.
  • Next, under the SSH category, select Auth.
  • In the resulting window, choose the private.ppk file we saved earlier as the Private key file for authentication.
  • Go back to the Session category which should still have the FOO session loaded.
  • Finally, click on the Save button to save our changes.

Once all the steps have been completed, we should be able to login automagically without having to manually enter the username and password every bloody time.

Hope this helps :)
P.S. FYI, some people have mentioned requiring the Pageant program (which comes packaged within the PuTTY installer) to get this working. I did not need to use it when I set things up here.