SSH Public Key Authentication with Putty and Pageant

Here is a quick step by step for setting up SSH Public Key authentication using Putty and its related tools.

To use these instructions, you will need to full set of Putty tools.

Generate the Keys

Run PuttyGen and then press “Generate”. Move your mouse in a random fashion over the blank area to help the generator add some randomness to the key.

Enter a comment which you will use to identify the key with and then enter a suitably complex passphrase.

Once all those details are in, save both the public and private key somewhere safe.

Upload public key to the server

Upload the public key to the server you wish to connect to and then start an SSH session.

Run the following command, replacing with the location of your public key

ssh-keygen -i -f >> ~/.ssh/authorized_keys

This will place your key in to a file called authorized_keys, which as it sounds is a list of keys which are authorised to access the server via SSH.

You may need to create the .ssh folder in your home directory, or your installation of OpenSSH may be looking for keys in a different place. Check the sshd_config file to make sure you are in the correct place if this doesn’t work.

Set up the connection in Putty

The server is now ready to accept our passwordless sign in.

Create a new session as normal by entering your host name.

Navigate to “Connection -> Data” in the left hand menu and enter your SSH username.

Then navigate to “Connection -> SSH -> Auth” and browse for you private key file.

Save the session and hit “Open”. You should now see  a window open and prompt you for your passphrase. Enter this and you will be logged in to your server.


To stop Putty prompting you for the passphrase every time, load the private key in to Pageant (Double clicking the .ppk file should do it). Pageant should prompt you for the passphrase, but will then keep the key unencrypted in memory for the next time you start a session. A small icon should now be in your notification area at the bottom right of your screen. Right click it and hover over “Saved Sessions”. You can use this to quickly start new putty sessions without entering any details or passwords.


Leave a Reply