SSH Key Generation
This document provides instructions for generating SSH key pairs (private and public) using different methods. SSH keys are used for secure authentication and encryption between a client and a server.
SSH Key Pair Generation Methods
This documentation covers two methods for generating SSH key pairs:
Using the command line on macOS and Unix operating systems.
Using PuTTYgen on Windows operating systems.
Method 1: Generating SSH Key Pair on macOS and Unix
To generate an SSH key pair on macOS and Unix operating systems, follow the steps below:
- Open a terminal or command prompt.
- Run the following command to generate an RSA key pair:
ssh-keygen -P '' -f transfer-key
This command generates an RSA key pair. The private key is saved as 'transfer-key' in the current directory, and the public key is saved as 'transfer-key.pub'.
- Run the following command to generate an ECDSA key pair:
ssh-keygen -t ecdsa -b 256 -N '' -m PEM -f transfer-key
This command generates an ECDSA key pair with a key size of 256 bits. The private key is saved as transfer-key in the current directory, and the public key is saved as transfer-key.pub.
Note: Valid values for the -b option for ECDSA are 256, 384, and 521. Adjust the value as per your requirements.
ssh-keygen -t ed25519 -f transfer-key
This command generates an ED25519 key pair. The private key is saved as transfer-key in the current directory, and the public key is saved as transfer-key.pub.
After generating the key pair, you will need to upload the public key to the desired server or service. The private key should be kept secure and should not be shared.
Method 2: Generating SSH Key Pair on Windows using PuTTYgen
Windows users can use PuTTYgen, a graphical tool, to generate SSH key pairs. Follow the steps below:
- Download and install PuTTYgen from the official website: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
- Launch PuTTYgen.
- Select the desired key type (e.g., RSA, DSA, ECDSA, ED25519) from the "Parameters" section.
- Click on the "Generate" button to create a new key pair.
- Follow the instructions to generate randomness by moving the mouse over the blank area of the PuTTYgen window.
- Once the key pair is generated, you can set an optional passphrase for added security. Enter the passphrase in the "Key passphrase" and "Confirm passphrase" fields.
- Click on the "Save public key" button to save the public key (.pub) to a location on your computer.
- Click on the "Save private key" button to save the private key (.ppk) to a secure location on your computer.
SFTP/FTP Clients
After generating the key pair, you can use the private key with popular SFTP clients for authentication. Here are a few examples:
FileZilla: In FileZilla, go to "Edit" -> "Settings" -> "SFTP" -> "Add key file" and select your private key file. Download FileZilla
WinSCP: In WinSCP, go to "Session" -> "SSH" -> "Authentication" and select your private key file. Download WinSCP
Remember to keep your private key secure and do not share it with anyone.
Updated 10 months ago