This guide describes how to generate a private and public key pair to log into a Linux server over SSH using Putty. Using key based exchange allows you to disable the normal username and password authentication procedure which increases security and removes the ability to brute force logins to the server.

Putty & Utilities

First off we need to download the following software:

  • Putty
  • Puttygen
  • Pageant

Creating Public and Private Keys

  1. Open PuttyGen
  2. Click on “SSH-2 RSA” at the bottom of the application
  3. Change “Number of bits in generated key:” to 2048
  4. Click “Generate”
  5. Move cursor around
  6. Change comment to¬†[email protected] eg: [email protected]
  7. Enter a password should you want to protect your private key (recommended)
  8. Click on “Save private key” and save to a safe location

Note: Keep PuttyGen open to get the public key information

Implementing Public Key

  • Log onto server
  • Create a folder called “.ssh” under the username you wish to auto log in as (if it doesn’t already exist)

Note: authorized_keys spelt the American way

  • Create a file called “authorized_keys” under the .ssh folder

  • Paste the contents of the public key into this folder
  • Change the write/readable only for that user

Adding Private Key to Pageant

  • Open Pageant
  • Click on “Add Key”
  • Enter password (if applicable)
  • Click OK
  • Click “Close”
  • A icon on the bottom right of your screen will appear

Creating Putty Saved Session

  • Add IP address or DNS name into “Host Name (or IP address) field
  • Select SSH
  • Add name to “Saved Sessions” field
  • (Optional) Click on Connection
  • (Optional)¬†Change “Seconds between keepalives” to 10
  • Click on Connection -> Data
  • Add the username you wish to auto login as
  • Click back on Session on the left hand side
  • Click Save
  • Double click on the saved session

Should you have any questions, comments or suggestions, please don’t hesitate to comment below. If you like what you have read, please share it on your favourite social media medium.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.