How to Generate a SSH Key pair

A straightforward yet comprehensive step-by-step guide that covers everything essential for setting up SSH key authentication on your server.

Generate SSH Key Pair on Windows using PuTTYgen

To generate an SSH key pair on Windows using PuTTYgen, follow these steps:

1. Download PuTTY and PuTTYgen: If you haven't already, download and install PuTTY from the official website.

2. Launch PuTTYgen: After installing PuTTY, launch the PuTTYgen program from the Start menu or installation directory.

3. Generate a New Key Pair: In the PuTTYgen window, follow these steps:

  • Under "Type of key to generate," select "RSA" (or any other desired key type).
  • Set the "Number of bits in a generated key" to a suitable value (4096 bits is fairly secure).
  • Click the "Generate" button. Move your mouse within the blank area to add randomness.

4. Provide a Key Comment (optional): Add an optional comment to help identify the key later.

5. Set a Key Passphrase (optional): Add a passphrase to secure your private key (important for security).

6. Save the Key Pair: After generation:

  • Click "Save public key" to save the public key to a file (e.g., "my_key.pub").
  • Click "Save private key" to save the private key to a file (e.g., "my_key.ppk"). Keep this private key secure.

7. Open the public key file That is "my_key.pub", in your favorite text editor to view it's content.

8. Conversion to OpenSSH Format (optional): If using OpenSSH:

  • Open the private key file in PuTTYgen.
  • Click the "Conversions" menu.
  • Choose "Export OpenSSH key" and save the private key with a .openssh extension (e.g., "my_key.openssh").

Generate SSH Key Pair on MacOS

1. Open Terminal: Launch the Terminal application on your macOS system. You can find it in the "Utilities" folder within the "Applications" folder or use Spotlight search.

2. Generate a New SSH Key Pair: In the Terminal, type the following command:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

Replace your_email@example.com with your email address. Press Enter to proceed.

3. Choose Key File Location: The command will prompt you to choose a location to save the key pair. Press Enter to save it in the default location (/Users/your_username/.ssh/id_rsa).

4. Set a Passphrase (Optional but Recommended): You can set a passphrase for added security. If you decide not to set one, press Enter twice. If you set a passphrase, remember it as you'll need it for each SSH session.

5. View Your Public Key: To view your newly generated public key, use the following command:

cat ~/.ssh/id_rsa.pub

This command will print your public key to the Terminal. You can copy and share it with servers you want to access.

Generate SSH Key Pair on GNU/Linux

1. Open Terminal: Launch your terminal emulator on your GNU/Linux system. You can typically find it in the "Applications" menu or by using keyboard shortcuts.

2. Generate a New SSH Key Pair: In the terminal, type the following command:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

Replace your_email@example.com with your email address. Press Enter to proceed.

3. Choose Key File Location: The command will prompt you to choose a location to save the key pair. Press Enter to save it in the default location (/home/your_username/.ssh/id_rsa).

4. Set a Passphrase (Optional but Recommended): You can set a passphrase for added security. If you decide not to set one, press Enter twice. If you set a passphrase, remember it as you'll need it for each SSH session.

5. View Your Public Key: To view your newly generated public key, use the following command:

cat ~/.ssh/id_rsa.pub

This command will display your public key. You can copy and share it with servers you want to access.

Upload to the server

That's it! You've generated an SSH key pair on your system. You can now use this key pair for secure authentication. Remember to keep your private key secure and never share it with others.

With your key pair generated, you can now use the private key for authentication in PuTTY or other SSH clients that support PuTTY's `.ppk` format or the OpenSSH format if you converted it.

Now, your next step involves copying your public key. Proceed to our SSH key management page. Here, paste the key into the designated 'SSH key data' field and assign a name to your key in the 'SSH key name' field. Conclude by selecting 'Upload' to successfully add your public key.

Upon successful completion, you will gain the ability to choose the designated public key while deploying a new server. This selection will facilitate the installation of the key onto your server, enabling you to establish connection and authentication through the private key file, which remains securely stored on your client.