5 min Read

How to Generate SSH Key in Windows in 3 Easy Ways

generate SSH key windows

Do you want to access your server and make changes according to your preferences? For this purpose, you will need an SSH key to connect to a remote server. Now let’s dive into this guide to know how to generate SSH key in Windows 10 or above.

What SSH Key in Windows and Why It is Used

Secure Socket Shell (SSH) keys are a means of authenticating a user to an SSH server without using a password. Every key is typically a key pair consisting of a public key and a private key.

The process of generating a pair of SSH key files, including a private key and a public key. The private key is only to the user’s computer, while the public key is used for the server. Both keys are useless without one another. Therefore, only users with both public and private keys can gain access to the server. However, the private key is never revealed to the server.

Furthermore, keys are more unattackable than passwords because they are significantly more complicated. While a password of eight characters is 72 bits long, SSH keys are often 2048 bits or lengthy. This longer string has many more possible modifications and, therefore, takes much more time to crack with an attack.

Generate an SSH key in Windows 10 or 11 via OpenSSH Client

Step: 1 Check and Install OpenSSH Client

Before generating the SSH key, ensure that OpenSSH Client is installed on your computer. To check this client is installed on your PC, follow these steps:

  • Go to the settings panel, and then click on Apps.
  • Below the Apps and Features heading, tap on Optional Features.
  • Scroll down and search to see if OpenSSH Client is listed.
OpenSSH Client
  • If it is not, hit the plus sign next to Add a feature.
  • Scroll through the app list to navigate and select OpenSSH Client.
  • Then, click on Install.

Step 2: Generate SSH key in Windows using Command Prompt

  • Open up the Start menu and search cmd.
run command prompt
  • Under the Best Match, open the Command Prompt.
type command in cmd
  • In the command prompt, type ssh-keygen and hit the enter button.
  • By default, the system will save the key file to C:\Users/username/ ssh/id_rsa. Either you can use this default name, or you can select a more descriptive name. It can help differentiate between keys if you are using multiple key pairs. Press enter if you do with the default option.
  • To skip this enter a passphrase step, press enter button.
generate key via cmd
  • The system will create the key pair and show the key fingerprint and a randomart image.
  • Now open the file browser and navigate to C:\Users\your_username/.ssh.
  • You should see two files are available in that folder. The identification is labeled in the id-rsa file and the public key is saved id_rsa_pub. It is your SSH key pair, and they both are saved in plain text.

Generate SSH Key on Windows Using PuTTY

Before the OpenSSH was combined with Windows, the PuTTY software was the benchmark for generating SSH keys. If you already have the PuTTy tool on your system or would like to utilize a graphical interface to originate your SSH key on Windows, this method is easy and suitable for you.

Step 1: Install and Run PuTTY SSH Key Generator

install puTTY gen
  • Download PuTTygen for Windows and install it on your PC.
  • After installation, press the Window key and type PuTTygen.
  • Under the Best Match, right-click PuTTygen and run as administrator.
  • Hit Yes on the Do you want to allow this app to make changes to your device? Pop-up.

Step 2: Use PuTTY to Generate a Pair of SSH Keys

The process mentioned below will create RSA keys, a classic and most used type of encryption algorithm. The PuTTy keygen software offers different other algorithms like DSA, ECDSA, Ed25519, and RSA (SSH-1).

generate key via PuTTy

If you need a different encryption algorithm, choose the desired option under the Parameters section before starting the generating process.

  • Click on the Generate in the PuTTy Key Generator window.
  • Move the cursor around in the blank gray area to fill up the green bar.

Save the public key:

save on pUTTy
  • Hit on the Save public key button.
  • Then, select a destination path to save the key.
  • A public key is saved with the .pub file extension.

Save the private key:

  • Click the Conversions tab at the upper side of the screen.
  • Then, select the Export OpenSSH key.
  • Click yes on the prompt if you want to save a key without a passphrase.
  • Select a destination to save the key. This key is saved without any file extension.

How to Generate an SSH Key in Windows Using WSL

The third method to create an SSH key is through the Windows Subsystem for Linux (WSL). But why would you prefer WSL when you already have the Windows Command Prompt?

WSL provides a complete Linux environment within Windows to run Linux commands without installing a separate operating system. It is beneficial for developers and system administrators working with Windows and Linux. Follow these steps to generate an SSH key using WSL.

  • Open the WSL terminal.
  • To generate an RSA-4096 key, type the following command and hit the Enter button.
  • ssh-keygen –t rsa –b 4096           
  • To create an Ed25519 key, change the command accordingly;
  • ssh-keygen –t ed25519
  • You could also enter your email address at the end of the command. If you generate different keys for different sites, it works like a tag to identify which key belongs to which account. For instance,  ssh-keygen –t –b 4096-C “[email protected].”
  • Select a destination for your key, or hit the Enter button to use the default location.
  • The terminal will allow you to choose a password. It is optional, so you can ignore it if you prefer. Hit Enter to continue.
  • At last, you will see a message with your newly created SSH key’s destination and fingerprint. Now, you can use this key to secure a connection between your computer and remote servers.

How to use SSH keys in Windows and Mac?

After you generate an SSH key in Windows, you will see two files: A public key for pasting into the OpenSSH authorized-key file and a private key for pasting into the SSH client. However, this public key is added to your remote server’s authorized key file. The private key should be kept secure and secret because if someone obtains your private key, they can access your server without requiring a password.

To copy the public key, click the public key to paste it into the OpenSSH authorized keys file, press Ctrl key + C for Windows, and on Mac, press Cmd + C.

After that, log into your remote server and open the ~/.ssh/authorized_keys file in your preferred text editor. Insert a new line at the end of the file and paste it into your public key that must start with ssh-rsa, then save and close the file.

Final Words

Generating an SSH key in Windows is a straightforward procedure, and it is something that every tech user should do to boost their security. However, you can generate an SSH key in Windows with the help of this guide. So what are you waiting for? Go ahead and try to keep your data safe and secure within a few easy steps.

Latest Update


Most Viewed

Picture of Trevor Mogg

Trevor Mogg

Lorem ipsum dolor sit amet consectetur. Cras in sed orci id. Malesuada sapien donec volutpat maecenas vulputate fringilla id. Lacus sociis massa aliquam semper. Nibh diam volutpat natoque lobortis sit tempor. Congue pretium eget mattis vulputate tempor.