Generate SSH Keys in Windows 11: A Step-by-Step Guide

The post provides a step-by-step guide on generating SSH key pairs in both Ubuntu Linux and Windows 11. For Windows 11, it takes advantage of the OpenSSH package, Windows Terminal, Command Prompt, or PowerShell for key creation. It also mentions that the generated key pairs can be accessed from the directory, C:\User\\.ssh. The tutorial stresses…

This post shows students and new users steps to generate or create SSH keys in Windows 11 or 10.

You will need an SSH key pair if you want to connect to an SSH server remotely using key authentication or use GitHub to manage your code.

In Ubuntu Linux and other Unix-like systems, generating and managing SSH keys and using key-based authentication is pretty easy.

Below is a post that shows you how to create an SSH key pair in Ubuntu Linux, which might also work in other Linux distributions.

How to create an SSH key for key authentication

The steps above might be slightly different when using a Windows machine. Windows 11 has a built-in OpenSSH package and commands that one can use to generate and manage keys from the Command Prompt, Windows Terminal, or PowerShell.

If you’re using the command line, you should use Windows Terminal, installed by default in Windows 11. Windows Terminal provides a better experience and features and can run the Command Prompt, PowerShell, and the Windows Subsystem for Linux in one window.

How to create SSH keys in Windows 11

As mentioned above, one can create or generate SSH keys in Windows 11. If you want to use SSH or SSH key-based authentication, you must create a pair of SSH keys.

The steps below show you how to do that in Windows 11

In Windows, to generate an SSH key, simply run the commands below and press Enter.

ssh-keygen

The command above will automatically create and generate a 2048-bit RSA key.

GitHub recommends generating an SSH key with the Ed25519 algorithm.

ssh-keygen -t ed25519 -C "your_email@example.com"

When you run the commands above, you’ll be prompted with the following lines asking to enter a location to save the file.

When prompted to “Enter a file in which to save the key,” press Enter to accept the default file location.

Generating public/private ed25519 key pair.
Enter file in which to save the key (C:\Users\Richard/.ssh/id_ed25519):

 If you use the defaults, then it will save your keys in C:\User\<username>\.ssh

Next, you’ll be asked to enter a passphrase. You typically leave this empty and press Enter. However, you can secure your SSH key by entering a passphrase so that you’re prompted for the passphrase every time you want to use the key to authenticate.

Created directory 'C:\Users\Richard/.ssh'.
Enter passphrase (empty for no passphrase):

After that, you should see a screen similar to the one below. Your SSH key pair should be created and ready to use.

Generating public/private ed25519 key pair.
Enter file in which to save the key (C:\Users\Richard/.ssh/id_ed25519):
Created directory 'C:\Users\Richard/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\Richard/.ssh/id_ed25519.
Your public key has been saved in C:\Users\Richard/.ssh/id_ed25519.pub.
The key fingerprint is:
SHA256:fXTi96BC8pHrLtqyBOrtKBeWvYSMigOKt9U898rd1Jo admin@example.com
The key's randomart image is:
+--[ED25519 256]--+
|                 |
|                 |
|            o .  |
|         . + o   |
| o +.   S = o o  |
|o *.o+   + + + o |
|*..o..= . + o . .|
|B.o+...=.+ + o   |
| =+oo o+++= E    |
+----[SHA256]-----+

Once the key generation process is complete, you can access the key pair at the location below.

C:\Users\<username>\.ssh

Replace <username> with your Windows account name.

That should do it!

Conclusion:

  • Generating SSH keys in Windows 11 is straightforward with the built-in OpenSSH tools.
  • Using the Ed25519 algorithm for SSH key generation is recommended for enhanced security.
  • Remember to save your keys in a secure location and choose a passphrase for added protection.
  • Once created, your SSH key pair can be easily accessed in the .ssh directory of your user profile.
  • Having SSH keys enables secure and convenient authentication when connecting to servers or using platforms like GitHub.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Exit mobile version