How to Generate an SSH Key Pair in Windows using PuTTY

PuTTY is a very common terminal used for SSH connections for Windows. However, the native PuTTY application was designed to be lightweight and does not include the key generation feature needed to create the SSH key pair required.

To Generate an SSH key pair to be used with PuTTY, you will need to use PuTTYgen. This small application comes packaged with the PuTTY installer but needs to be accessed separately.

Generating SSH Key Pairs with PuTTYgen

How to Generate an SSH Key Pair in Windows using PuTTY
  • Step 1. In your Windows search bar, look for PuTTYgen to see if you installed it with PuTTY. If it was not, you would need to download and install it separately. When done, launch PuTTYgen.
  • Step 2. Under the “Parameters” label, select “RSA” as the type of key, then click the “Generate” button. You will be asked to move your mouse around randomly – remember to do this within the small blank area under the “Key” label.

Keep moving your mouse until the key information appears. 

  • Step 3. Type in the password you choose into the “Key Passphrase” field and again in the “Confirm passphrase” field. This passphrase will be needed when making the SSH connection later.
  • Step 4. Save the private key on your computer. You can also save the public key, though it’s not really necessary because you can easily access it by loading the private one in PuTTYgen. If you’re going to configure your server to work with the key pair right now, it’s best to leave the PuTTYgen window open.

Using SSH Keys For Authentication on an SPanel Server

With the keys generated, you need to configure your server and your client to work with them. Here’s what you need to do if you use PuTTY to connect to an SPanel VPS.

  • Step 1. Log in to your SPanel server using your username and password.
How to Generate an SSH Key Pair in Windows using PuTTY
  • Step 2. Public SSH keys used for authentication are stored in ~/.ssh/authorized_keys. If this is the first key you’re saving on your account, you’ll need to create the file yourself.

Here are the commands:

$ mkdir .ssh


$ touch .ssh/authorized_keys

NOTE: Make sure you run these commands from your account’s home directory. If you’re not sure whether you’re in the right place, you can use $cd ~ to navigate to it.

  • Step 3. Set the file’s ownership and permissions. If you skip this step, your SSH client will be unable to access your public key and log you in. The commands you need to use are:

$ chmod 700 .ssh

$ chmod 600 .ssh/authorized_keys

$ chown $[your username]:[your username] .ssh -R

How to Generate an SSH Key Pair in Windows using PuTTY
  • Step 4. The next step is to paste your public key inside the authorized_keys file. You need to go back to the PuTTYgen window and copy your public key from the field at the top. Make sure you select every single character.
How to Generate an SSH Key Pair in Windows using PuTTY

Now, go back to the command-line interpreter and enter the following command:

$ nano .ssh/authorized_keys

This opens the authorized_keys file in the GNU nano text editor. A simple right-click pastes your public key into the file. Press Ctrl+x and confirm that you want to save the changes.

If you want to add another public key, you need to paste it on a new line.

  • Step 5. Finally, it’s time to configure PuTTY to work with the new key pair. Open the client and go to SSH > Auth. Click the Browse button and select your private key.
How to Generate an SSH Key Pair in Windows using PuTTY

Next, you can go to the Session menu and make sure you’ve entered the correct details for the host. If you click Save, PuTTY will store the configuration, and you won’t need to select your private key every time you want to log in.

How to Generate an SSH Key Pair in Windows using PuTTY

After you click Open, PuTTY will use your private key to establish a connection to the server. If you’ve configured your key pair to use a passphrase, you’ll need to enter it at this point.

How to Generate an SSH Key Pair in Windows using PuTTY

Was this helpful?

What’s your goal today?

1. Find the right Web hosting solution

If you’re looking for industry-leading speed, ease of use and reliability Try ScalaHosting with an unconditional money-back guarantee.

2. Make your website lighting fast

We guarantee to make your WordPress site load in less than 2 seconds on a managed VPS with ScalaHosting or give your money back. Fill out the form, and we’ll be in touch.

Please enter a valid name
Please enter a valid website
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

3. Streamline your clients’ hosting experience

If you’re a web studio or development agency hosting more than 30 websites, schedule a call with Vlad, our co-founder and CTO, and see how we can deliver unmatched value to both your business and your clients.


Need a custom cluster or professional advice?

Book a meeting and get a free 30-minute consultation with Vlad, co-founder & CTO of Scala Hosting, who will help you select, design and build the right solution - from a single data center cluster to a multi-region & multi-datacenter high availability cluster with hundreds of servers.

Book a free consultation

4. Learn how to grow your website in 2023

An all-star team of SEO and web influencers are sharing their secret knowledge for the first time in years. Learn about the future of SEO, Web Design best practices and the secrets to getting the foundation for your website to thrive. Watch the exclusive webinar.

An Exclusive Insiders Look Behind The SEO and Web Development Curtain


Working in the web hosting industry for over 13 years, Rado has inevitably got some insight into the industry. A digital marketer by education, Rado is always putting himself in the client's shoes, trying to see what's best for THEM first. A man of the fine detail, you can often find him spending 10+ minutes wondering over a missing comma or slightly skewed design.