Generating an SSH key is a key step in securing connections to servers, especially when working remotely or managing servers over SSH. In this tutorial, you’ll learn how to generate an SSH key pair (public and private) on Windows and what precautions to take to protect the private key.
Windows 10 and 11 have the OpenSSH tool built-in, but you can also download the PuTTY tool if you prefer an alternative approach. To check if you have the OpenSSH tool installed, follow these steps:
ssh
If you see a list of options and commands, it means you have the SSH client installed. If not, go to Windows Settings, choose Applications > Optional Features and make sure OpenSSH is installed.To generate the SSH key, we will use PowerShell:
ssh-keygen
You will be asked where to save the key. By default, the key will be saved in the directory: C:\Users\YourUser\.ssh\id_rsa
After generating the keys, you will see two files:
A private key should be treated like confidential information. Here are some tips on how to protect it:
icacls C:\Users\YourUser\.ssh\id_rsa /inheritance:r /grant:r %username%:F
This command will remove the inheritance of permissions and grant full access only to you.Generating an SSH key is a simple process, but the security of your private key depends on following best practices. Take care to protect it, use a password and back it up regularly. These steps will keep your SSH connections secure and reliable.
Hopefully, this guide has made the process of generating an SSH key on Windows easier for you. If you have additional questions, feel free to contact an IT expert!