linux-logo-300x300

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 2048PuttyGen SSH2 @ 2048bits
  4. Click “Generate”
  5. Move cursor aroundPuttyGen Key Generation
  6. Change comment to username@ipaddress eg: root@123.456.789.101
  7. Enter a password should you want to protect your private key (recommended)PuttyGen Private Key Settings
  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)Pageant Add Key
  • Click OKPageant Add Key
  • Click “Close”
  • A icon on the bottom right of your screen will appearPageant

Creating Putty Saved Session

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

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.