Linux Commands

How to Generate SSH Keys on Windows 10/11 to Access Linux Servers without Passwords

In this article, we will show you how to generate the SSH keys on Windows 10 and Windows 11 operating systems. We will also show you how to install the generated public SSH key of Windows 10 and Windows 11 on Linux servers so that you can access them via SSH without passwords.

Topic of Contents:

  1. Install the SSH Client on Windows 10/11
  2. Generate the SSH Keys on Windows 10/11
  3. Find the Generated SSH Public Key on Windows 10/11
  4. Access the Linux Servers from Windows 10/11 via SSH
  5. Copy the SSH Public Key from Windows 10/11 to Linux Servers
  6. Check If the Passwordless SSH Login to Linux Servers Work from Windows 10/11
  7. Conclusion

Install the SSH Client on Windows 10/11

To generate the SSH keys on Windows 10 and Windows 11, you must have the OpenSSH client program installed on your Windows 10/11 operating systems.

Read this article if you need any assistance in installing the OpenSSH client program on Windows 11.

Read this article if you need any assistance in installing the OpenSSH client program on Windows 10.

Generate the SSH Keys on Windows 10/11

To generate the SSH keys on Windows 10/11, you need to open a Terminal program.

Read this article if you need any assistance in opening a Terminal program on Windows 11.

Read this article if you need any assistance in opening a Terminal program on Windows 10.

Once you open the Terminal program, run the following command to generate an SSH key on Windows 10/11:

$ ssh-keygen

Press <Enter>.

Press <Enter>.

Press <Enter>.

A new SSH key should be generated.

Find the Generated SSH Public Key on Windows 10/11

You can find the generated SSH public key in the C:\Users\<your-username>\.ssh folder of your Windows 10/11 operating system. Here, <your-username> is the username of your Windows 10/11 operating system.

Open the “File Explorer” app and navigate to the C:\Users\<your-username>\.ssh folder.

You will find the “id_rsa.pub” file here. You need to copy the contents of this file. Open it with a text editor app, i.e. “Notepad”. To do that, double-click (LMB) on the “id_rsa.pub” file.

Select “Notepad” from the app list and click on “Always”.

The “id_rsa.pub” file should be opened with the “Notepad” app.

Select the contents of the “id_rsa.pub” file by pressing <Ctrl> + A. Then, press <Ctrl> + C to copy the selected contents.

Access the Linux Servers from Windows 10/11 via SSH

Now, you have to SSH into the Linux server that you want to access without passwords from your Windows 10/11 operating system. If you need any assistance on that, read the article on How to SSH into the Linux Servers from Windows 10/11.

Copy the SSH Public Key from Windows 10/11 to Linux Servers

Once you access the Linux server via SSH, paste the SSH public key of your Windows 10/11 operating system (that you copied earlier) in the ~/.ssh/authorized_keys file of your Linux server.

To do that, open the ~/.ssh/authorized_keys file of your Linux server with the following command:

$ nano ~/.ssh/authorized_keys

OR

$ vi ~/.ssh/authorized_keys

The ~/.ssh/authorized_keys file should be opened with your desired text editor.

If you opened the “authorized_keys” file with the “nano” text editor, simply right-click (RMB) on the terminal program and the copied text (SSH public key of your Windows 10/11 machine) should be pasted.

If you used the “vi” text editor to open the “authorized_keys” file, press <i> to go to “insert mode” and right-click (RMB) on the terminal to paste the copied SSH public key.

Once you paste the SSH public key, save the ~/.ssh/authorized_keys file.

If you use the “nano” text editor, press <Ctrl> + X followed by Y and <Enter> to save the “authorized_keys” file.

If you use the “vi” text editor, press <Esc> to go back to “command mode”. Then, type in :wq! and press <Enter> to save the “authorized_keys” file.

The ~/.ssh/authorized_keys file should be saved as you can confirm by reading the contents of the “authorized_keys” file.

$ cat ~/.ssh/authorized_keys

Now, close the SSH session with the following command:

$ exit

Check If the Passwordless SSH Login to Linux Servers Work from Windows 10/11

Now that you installed the SSH public key of your Windows 10/11 operating system on the Linux server, you should be able to log in to your Linux server without a password.

To check whether the passwordless login to your Linux server is working from Windows 10/11, open the Terminal app on Windows 10/11 and try to SSH into your Linux server.

$ ssh <username>@<hostname>

NOTE: Make sure to change the <username> and <hostname> with the login username and domain name/IP address of your Linux server respectively.

You should be logged in to your Linux server (without needing to enter a password).

Conclusion

We showed you how to generate an SSH key on Windows 10 and Windows 11 operating systems. We also showed you how to install the SSH public key (of your Windows 10 and Windows 11 operating systems) on a Linux server so that you can SSH into it (from Windows 10 and Windows 11) without needing to enter any passwords.

About the author

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.