Using SSH Keys and Putty to Access Remote Servers

This tutorial assumes that you have a basic level of knowledge of Linux commands and can access a remote system using SSH. You will need PuTTY & PuTTYgen.

Direct links to portable versions of both applications are above, but you can also download a windows installer that has everything that you need from here.

Using PuTTYgen to generate a key pair

Open PuTTYgen and create a new key pair. The on-screen prompts are self explanatory and the defaults will work just fine.

Save a copy of each of the keys. It’s probably wise to password protect your private key so that it can’t be stolen. Keep both keys somewhere safe.

Select all the text in box labeled ‘Public key for pasting into OpenSSH authorized_keys file’ and copy it to the clipboard. The sequence should start with "ssh-rsa".

Preparing your SSH server.

Login to your SSH server. Navigate into your .ssh folder and paste the SSH key into the authorized_keys file. If it isn’t there, create it:

mkdir ~/.ssh
chmod 0700 ~/.ssh
touch ~/.ssh/authorized_keys
chmod 0644 ~/.ssh/authorized_keys

You can logout from your server for now.

Preparing PuTTY to login with your private key file.

Fire up PuTTY and enter the host name and port for your SSH server. In the navigation tree on the left, click ‘Data’ and enter the user name that you use to login to your SSH server.

Now click on ‘SSH’ and then ‘Auth’. Click browse and locate the private key file that you generated with PuTTYgen.

Scroll to the top of the navigation tree and click on ‘Session’. In the ‘Saved Sessions’ box, give your session and name and hit Save.

That’s it. Your SSH server and PuTTY are now ready to connect without passwords.