Login to Linux using SSH Keys in PuTTY

This post provides a quick guide to configuring access to a Linux account using SSH keys.

Generate a Private and Public Key Pair

  1. Download puttygen.exe from here.
  2. Click Generate.
  3. Move the mouse until complete.
  4. Enter the "Key passphrase".
  5. Click Save public key.
  6. Click Save private key.
  7. Copy the value of the public key in the box on the top (see screenshot) (Do not copy the trailing rsa-key-20210206 at the end of the string!)

Configure the Linux Server

  1. Login to the Linux account you want to give access to.
  2. Run these commands and paste the contents of your public key (from Step 7 above) here:
mkdir ~/.ssh
chmod 700 ~/.ssh
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
vi ~/.ssh/authorized_keys

Configure Session in PuTTY

  1. Make sure you have the Linux hostname and .ppk file to configure a new PuTTY session.
  2. When configuring a new session in PuTTY, navigate to Connection > SSH > Auth and enter the location of your private key .ppk file on your local file system.

Logging in to PuTTY

  1. Upon login, you will be prompted for the Linux username and the private key password.

Exporting PuTTY .ppk Private Key to .pem Format

  1. In PuTTY Key Generator, select Conversions > Export OpenSSH Key.
  2. Name the file and add the .pem extension.
  3. Choose Save.