Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Create an SSH Key on Windows with PuTTYgen

This guide shows you how to make an SSH key pair on Windows using PuTTYgen. You can then log in to a server without typing its password each time.

Windows Hosting2 min read17 steps

What is an SSH key?

SSH is a safe way to control a server by typing commands. An SSH key pair has two parts. The public key is like a lock. You put it on the server. The private key is like the only key that opens that lock. You keep it secret on your computer.

PuTTY is a free SSH program for Windows. PuTTYgen comes with it and makes keys. If you do not have PuTTY yet, see our guide on installing PuTTY.

Steps

  1. Click Start, type PuTTYgen and open it.
  2. Under Type of key to generate, choose RSA (or EdDSA if you prefer).
  3. For RSA, set Number of bits to 4096 (or at least 2048).
  4. Click Generate.
  5. Move your mouse over the blank area. This random movement helps create a strong key.
  6. When the key shows, type a passphrase in Key passphrase and again in Confirm passphrase. A passphrase is a password that protects the private key if someone steals your file.
  7. Click Save private key. Save the .ppk file in a safe folder.
  8. Click Save public key if you want a copy of it as a file.
  9. Select all the text in the top box, called Public key for pasting into OpenSSH authorized_keys file, and copy it.

Put the public key on the server

  1. Log in to the server with your password.
  2. Open the file ~/.ssh/authorized_keys. If the folder does not exist, make it:
    mkdir -p ~/.ssh
    nano ~/.ssh/authorized_keys
    The first line creates the folder. The second opens the file in a simple editor.
  3. Paste the public key on a new line. Save with Ctrl + O, then Enter, and exit with Ctrl + X.
  4. Set safe permissions:
    chmod 700 ~/.ssh
    chmod 600 ~/.ssh/authorized_keys
    These commands make the files private to you.

Use the key in PuTTY

  1. Open PuTTY and type the server IP in Host Name.
  2. In the left menu, open Connection, then SSH, then Auth, then Credentials.
  3. Click Browse beside the private key box and pick your .ppk file.
  4. Go back to Session, click Open and log in.
Warning: Never share your private key. Back it up in a safe place. If you lose it, you must add a new key.

Quick recap

  • A key pair has a public key (the lock) and a private key (the key).
  • Use PuTTYgen, click Generate, add a passphrase and save the private key.
  • Paste the public key into authorized_keys on the server.
  • Select the .ppk file in PuTTY to log in.