Key-Based SSH Logins With PuTTY

This guide describes how to generate and use a private/public key pair to log in to a remote system with SSH using PuTTY. PuTTY is an SSH client that is available for Windows and Linux (although it is more common on Windows systems). Using key-based SSH logins, you can disable the normal username/password login procedure which means that only people with a valid private/public key pair can log in. That way, there is no way for brute-force attacks to be successful, so your system is more secure.


1 Preliminary Note

In this tutorial I use a Windows desktop to connect to a Linux SSH server (Debian with IP address:


2 Install PuTTY, PuTTYgen, And Pageant On The Windows System

First we need to install PuTTY, PuTTYgen, and Pageant on our Windows system. All we need to do is download the exectuable files (.exe) and save them somewhere, e.g. on the desktop. We don't need to install them as they are standalone applications. To start them, we only need to double-click them.

Download the following files from the PuTTY download page and save them on your Windows system, e.g. on the desktop:


3 Create A Profile With Settings For Our Server

In PuTTY, you can create profiles for connections to your various SSH servers, so you don't have to type in the settings again when you want to connect to a certain server again.

Let's create a profile for our server. Start PuTTY by double-clicking its executable file. You are now in the category Session (see the tree on the left side of the screenshot). Enter under Host Name (or IP address), enter 22 under Port and select SSH under Protocol:

Then go to Connection -> Data and specify the username with that you want to log in to your SSH server under Auto-login username. In this article I use root:

Then go to Session again. Under Saved Sessions enter a name for the profile, e.g. or any other string that lets you remember for which server the profile is. Then click on Save:

The next time you use PuTTY, you can simply select the appropriate profile from the Saved Sessions textarea, click on Load and then Open.

Share this page:

16 Comment(s)

Add comment


From: FalconsMaze

Thank you for the detailed screen shots and hand holding.  I was able to set this up in five minutes.  On other blogs there are a lot of steps omitted or :"your just suppose to know that setup."

Awesome job!


From: dcb

This is well explained thank you. Putty does it's job well, but there are few instructions around that explain how to use it. The messages from failed login attempts rarely give any clues about how PuTTY should be set up. Many thanks for taking the time to document these settings and explain them so clearly. It is much appreciated.


From: DizzyBum

Thanks for this article!  I use Putty non-stop at work and this is going to cut out a lot of the time I spend copying and pasting long passwords.  Very clear and simple instructions.

From: Brian

Thanks for explaining the whole process! I had stumbled through the key generation but couldn't figure out how to get the public key to the server in the right spot. I've bookmarked this page for future reference, because at my new job I've got a lot of servers to ssh to.

From: thatsimonguy

This post really helped me and I was able to successfully setup a private/public keypair between my Win7 machine and my Ubuntu box for login.  Thanks.

From: alex_rsku

What if I want to create few pub keys? Should I append these keystrings to authorized_keys2 , what separators are ?

From: M. Gy.

Authorized keys are checked in both ~/.ssh/authorized_keys and authorized_keys2 by default. openSUSE (and maybe other) distros do not use authorized_keys2, so if you cannot login with your brand nem key pair, try to rename the file to authorized_keys.

Rgrds - M. Gy.

From: M. Gy.

Switching off PAM (usePAM no) in /etc/ssh/sshd_config has some side effects. It is safer to write:

ChallengeResponseAuthentication no

instead. It still disables keyboard-interactive login, but leaves PAM to be used.

From: M. Gy.

A 2048 bits long key can be used, it is safer and it is now the default in PuTTYGEN.

From: abhishek

thank you.

From: Markus


From: Jameel Isaacs

Hi there,

I am struggling to do step 6, could you please advise a more detailed step process

Kind regards


From: Zdenek

Thank you very much. Excellent job!

From: steffen

how to do this with cacert .org client certificates instead of putty "self-signed" certs?

From: Kotzaak

Thanks for this very clear document! Helped me out in 20 minutes :)

From: john

Excellent instructions, but for me on Ubuntu 14 and windows 8.1, it does not work. I followed every step to the letter, but when I try to login with putty (with the ppk file set), it just prompts for the username and password as usual - doesnt do anything with the cert. The permissions on ~/.ssh and the keys file are correct, as is the thing which I pasted in (same format as yours, on one line).  The problem with ssh is it never works for me, and its hard to debug where the problem might be.