An SSH key pair is a set of security credentials that allows you to log into a remote server or service securely, consisting of public and private keys.

The public key is used to encrypt the connection, while the private key is used to decrypt it.

This article will explain how to generate SSH key pairs in various platforms, including Linux, Windows, cPanel, and Bitvise SSH Client (which is easier for beginners).

How to Generate SSH Key Pairs in Linux

In this section, I will share how to generate SSH key pairs using OpenSSH in Linux. OpenSSH is a free and open-source implementation of the SSH protocol that is included in most Linux distributions.

Prerequisites

Before you begin, make sure you have a terminal emulator installed on your Linux system. You can use the built-in terminal emulator or any other terminal emulator of your choice.

Generating SSH Keys using Linux Terminal

To generate an SSH key pair using OpenSSH in Linux, follow these steps:

  1. Open a terminal and run the following command: ssh-keygen -t rsa -b 4096 -C "[email protected]$HOSTNAME"
  2. Press Enter to use the default location and filename for the key pair.
  3. OPTIONAL: Enter a passphrase to secure the private key. A strong and unique passphrase is recommended to protect the private key from unauthorized access.
  4. Press Enter to confirm the passphrase.

The ssh-keygen -t rsa -b 4096 -C "[email protected]$HOSTNAME" command will generate a public key and a private key in the ~/.ssh directory. The public key will be saved as ~/.ssh/id_rsa.pub , and the private key will be saved as ~/.ssh/id_rsa.

Done! You have successfully generated an SSH key pair using the SSH Terminal.

How to Generate SSH Key Pairs in Windows

Generating an SSH key pair on Windows is a straightforward process, and it can be done using a built-in tool called “Powershell” and a 3rd party feature known as the “Windows Subsystem for Linux (WSL)”.

In this section, I will walk you through the steps of generating SSH key pairs in Windows using Powershell and WSL.

Generating SSH Keys using Powershell

If you prefer to use a command-line interface to generate an SSH key pair on Windows, you can use the built-in Powershell tool. Powershell is a powerful and flexible command-line tool that is included with all modern versions of Windows.

Prerequisites

Before you begin, make sure that you have the following prerequisites:

  • Windows 7 or later
  • PowerShell 2.0 or later

To generate SSH Keys using Powershell, follow the steps below:

  1. Open Powershell by clicking on the Start menu and searching for “Powershell.”
  2. Run the following command to generate an SSH key pair:
ssh-keygen -t rsa -b 4096 -C "[email protected]$HOSTNAME"

Replace “[email protected]$HOSTNAME” with your preferred note. This will create an RSA-type key pair with a length of 4096 bits.

  1. You will be prompted to enter a file to save the key. Press Enter to accept the default location, or enter a different location if you prefer.
  2. You will be prompted to enter a passphrase for the key. You can either leave this blank or enter a passphrase to secure your key.
  3. The ssh-keygen tool will generate your SSH key pair and save it to the specified location.

That’s it! You have successfully generated an SSH key pair using Powershell.

Generating SSH Keys using Windows Subsystem for Linux (WSL)

Windows Subsystem for Linux (WSL) is a feature of modern versions of Windows that allows you to run a full Linux environment directly on your Windows machine.

If you have WSL installed on your Windows machine and you prefer to use a Linux-style command-line interface to generate an SSH key pair, you can do so by following these steps:

  1. Open the Start menu and search for “Bash.” This will launch the Linux terminal on your Windows machine.
  2. Run the following command to generate an SSH key pair:
ssh-keygen -t rsa -b 4096 -C "[email protected]$HOSTNAME"

Replace “[email protected]$HOSTNAME” with your preferred note. This will create an RSA key pair with a length of 4096 bits.

  1. You will be prompted to enter a file in which to save the key. Press Enter to accept the default location, or enter a different location if you prefer.
  2. You will be prompted to enter a passphrase for the key. You can either leave this blank or enter a passphrase to secure your key.
  3. The ssh-keygen tool will generate your SSH key pair and save it to the specified location.

If you followed all the steps above, you should have successfully generated an SSH key pair using WSL on your Windows machine.

How to Generate SSH Key Pairs using Bitvise SSH Client

Bitvise SSH Client is a popular Windows-based SSH client that allows you to connect securely and EASILY to remote servers and services. In addition to providing a secure and easy way of connecting to remote servers, Bitvise SSH Client also includes a tool for generating SSH key pairs. Here’s how to use Bitvise SSH Client to generate an SSH key pair:

  1. Download and install the Bitvise SSH Client from the official website (https://www.bitvise.com/ssh-client-download).
  2. Launch Bitvise SSH Client and click on the “Client key manager” link within the Login Tab.
  3. Click on the “Generate New” button to create a new SSH key pair.
  4. Follow the on-screen instructions to generate your SSH key pair. You will be asked to specify the type of key to generate (RSA or DSA), the key length, and the passphrase (if desired).
  5. You can easily export your public and private keys from the Client key manager when complete.

That’s it! You have successfully generated an SSH key pair using Bitvise SSH Client.

How to Generate SSH Key Pairs in cPanel/WHM

cPanel is a popular web hosting control panel that provides an easy-to-use interface for managing your web hosting account. If you have a cPanel-based server or a hosting account, you can also use this platform to generate SSH key pairs.

To generate an SSH key pair using cPanel as root and user account, follow these steps:

  1. Log in to your WHM account or a cPanel User account.
  2. In the “Security” section, click the “Manage Root’s SSH Keys” for the WHM account and the “SSH Access” icon in a cPanel User account.
  3. Click the “Manage SSH Keys” button.
  4. Click the “Generate a New Key” button.
  5. OPTIONAL: Enter a name for the key pair and a passphrase to secure the private key. A strong and unique passphrase is recommended to protect the private key from unauthorized access.
  6. Click the “Generate Key” button.

The new SSH key pair will be displayed on the “Manage SSH Keys” page.

How to Generate SSH Key Pairs In Various Platforms – Step by Step (Video Tutorial)

Cheat Sheet Commands shown in the video:

Generate ssh keys within your current directory:

ssh-keygen

OR add security:

ssh-keygen -t rsa -b 4096

OR Add comment:

ssh-keygen -t rsa -b 4096 -C "your-comment"

To generate with a specific destination:

cd ~/.ssh
ssh-keygen -t rsa -b 4096 -C "your-comment"

OR:

ssh-keygen -t rsa -b 4096 -C "your-comment" -f ~/.ssh

To generate with security and specific destination/filename:

ssh-keygen -t rsa -b 4096 -C "comment" -f ~/.ssh/filename

To generate with security with a specific destination/filename, a passphrase and a comment containing the user and hostname:

ssh-keygen -t rsa -b 4096 -C "[email protected]$HOSTNAME" -P -f ~/.ssh/filename

Final thoughts

Generating an SSH key pair is important in securing your remote server or service.

Whether you are using a graphical user interface or a command-line interface, several different tools are available for generating SSH key pairs on various platforms.

By following the steps outlined in this article, you can easily generate an SSH key pair using the Linux Terminal, Powershell, WSL, Bitvise SSH Client, or in the cPanel platform as root and a user account.

Once you have generated your SSH key pair, you can log into your remote server or service securely without entering a password or passphrase if desired.

Moving Forward

This video is part of my Make Money with Websites (Free Full Course), and don’t forget to hit the Subscribe button to get the latest Free tutorials from me.

👉 MORE TUTORIALS YOU MIGHT LIKE:
Make Money w/ Websites (FREE Course) https://bit.ly/3zQ6oAJ
FREE Hosting for WordPress (FREE Course) https://bit.ly/3YgZ8ti
Webmaster & SysAdmin Tutorials https://bit.ly/3hgY87E
More FREE Courses & Tutorials https://bit.ly/3hgY87E

💡 RECOMMENDED
Learn more from me by joining my newsletter
Niche Websites for Sale https://mauwiks.com/niche-website-seller
Business Tools & Services I have used https://mauwiks.com/resources
Hire Me for Freelancing Services https://mauwiks.com/freelancing