SSH key conversion
PuTTYgen
ssh-agent
Keychain
cross-platform compatibility

How to convert SSH keypairs generated using PuTTYgen Windows into key-pairs used by ssh-agent and Keychain Linux

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

Working with SSH key pairs on different operating systems can be challenging due to varying formats and conventions. While Windows users often use PuTTYgen to generate SSH keys, Linux systems commonly use OpenSSH and tools like ssh-agent and keychain for key management. This guide provides a step-by-step process to convert SSH key pairs generated with PuTTYgen on Windows into formats compatible with ssh-agent and keychain on Linux. We will also cover technical details, provide explanations, and illustrate the process with examples.

Prerequisites

  1. PuTTYgen: A key generator for PuTTY on Windows.
  2. OpenSSH: Available by default on most Linux distributions.
  3. Keychain: An application to manage SSH keys in a user session.
  4. Command-line access: Both Windows and Linux terminal usage is necessary.

Key Conversion Steps

Step 1: Generate SSH Key in PuTTYgen

  1. Open PuTTYgen on your Windows machine.
  2. Select the desired key type (e.g., RSA) and key size (2048 bits is common).
  3. Click on "Generate" to create a new key pair.
  4. Move your mouse over the blank area to create entropy.

Step 2: Save the Private Key Using PuTTYgen

  1. Once the key is generated, click on "Save private key". Choose a file location and save it as privatekey.ppk.
  2. Optionally, you can assign a passphrase to enhance security.

Step 3: Export the OpenSSH Key

  1. Export the public key: In the PuTTYgen window, select "Conversions" → "Export OpenSSH key". Save this file as id_rsa.
  2. Copy the public key: Displayed in the PuTTYgen interface, copy the OpenSSH-format public key for your remote server. You can save this in a text file named id_rsa.pub.

Step 4: Transfer Keys to Linux

  1. Use a method to transfer both id_rsa (private key) and id_rsa.pub (public key) securely to your Linux machine. Some common methods are:
    • Email: Send it to yourself.
    • USB Storage: Transfer files using a USB stick.
    • Secure Copy (SCP): Use SCP if network-sharing is set up.

Step 5: Set Proper Permissions on Linux

Once the keys are on the Linux machine:

  1. Move the key files to your SSH directory:

Course illustration
Course illustration

All Rights Reserved.