If you want to remotely connect to an SSH server using key authentication or use GitHub to manage your code, you will need an SSH key pair. 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 and use the public key to authenticate to an SSH server. How to create an SSH key for key authentication When you’re using a Windows machine the steps above might be a bit different. Windows 11 comes with 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 going to be using the command line, then you should use Windows Terminal which is 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 all 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 key authentication or use SSH key-based authentication, you will need to create a pair of the SSH key. 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. The command above will automatically create and generate a 2048-bit RSA key. GitHub recommends generating an SSH key with the Ed25519 algorithm. When you run the commands above, you’ll be prompted with the following lines asking to enter a location to save the file. When you are prompted to “Enter a file in which to save the key,” press Enter to accept the default file location.  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. After that, you should see a similar screen to the one below. Your SSH key pair should be created and ready to use. Once the key generation process is complete, you should be able to access the key pair at the location below. Replacing with your Windows account name.

How to copy your public key to the SSH server with Windows 11

Now that you’ve generated your SSH key pair, you will want to copy your public key to the SSH server. On Unix-like systems, ssh-copy-id is a tool for copying SSH keys to the server. However, Windows doesn’t have the ssh-copy-id tool installed. To get your public SSH to the server and enable password-less login, you may have to use PowerShell to do the same in Windows 11. To copy your SSH key to the server, open Windows Terminal, then copy and paste the line below then press Enter. Replace {IP-ADDRESS} with the server IP address. If you don’t already have a ~/.ssh/authorized_keys file at the destination location, run the Linux commands below to create one. Re-run the command above again to copy your key to the server.

How to configure SSH for passwordless login

Now that you’ve copied over your public key, the next step is to disable password authentication. Log on to the remote server with your password, then open the SSH configuration file by running the commands below. In the file, find the lines below and change the value to match these. Save the file and exit. Restart the SSH server on the remote host. After that, password login should be disabled. Next type simply typing the command below will log you in without a password prompt. That should do it! Conclusion: This post showed you how to generate an SSH key in Windows 11 and then use the key to authenticate to an SSH server. If you find any error above or have something to add, please use the comment form below.