How to generate ssh-key in Windows



Generate ssh-key in Windows 11 using powershell

You already are familiar with ssh and ssh-key usage so how to generate it in windows?

Open powershell and type “ssh-keygen” and press enter:

ssh-keygen
  1. You will be prompted to define the path but press Enter to accept the default path: “C:\Users\username/.ssh/id_rsa”
  2. you will be prompted again to enter a password or press enter for no password.
  3. Enter your password again if you entered password in last step, otherwise press enter.

Now your ssh-key private key (id_rsa) and your public key (id_rsa.pub) are genrated and saved in .ssh folder.

If you have problem with ssh please have a look at my other post: How to fix ssh connection error

Generate ssh-key in windows using ssh-keygen command

You can use a third party software to generate ssh-key and for ssh remote access. A good example is “Putty”. A FOSS(Free Open Source Software) terminal emulator, serial console and a network file transter application. Putty supports protocols like ssh, telnet, rlogin, scp and raw socket connection.

For basic tasks like using ssh and managing ssh keys, the built-in terminal or PowerShell on platforms like Windows and Linux might be a smoother experience compared to using a separate tool like Putty. In my experience with Putty, setting up and using ssh and ssh-key management felt more complex and time-consuming compared to the native terminal.



What is ssh-key and why you need it?

SSH keys are a type of credential used in the Secure Shell (SSH) protocol for secure remote access. It is a two part authentication system:


  1. Private key: Private key stays securely stored on your local machine and is never shared. It acts like a digital signature unique to you.
  2. Public key: Public key is freely shared with servers or services you want to access. It can verify your identity without revealing your private key.

Why use an ssh-key?

How ssh-key helps with securing remote access to servers?

  1. It is convenient! You set up the ssh-key once and you can often log in to servers without entering password (if you set ssh key with no password).

  2. It helps with automated tasks! Automated tasks and scripts can use ssh-key to access servers

  3. It enhances security! ssh-key is harder to compromise or to intercept. Even if someone gets your public key, it would be impossible to decrypt the private key needed for access and login.


Common ssh-key use cases

Accessing remote servers: System administrators and developers often use ssh keys to manage servers securely.
Connecting to Git repositories: Platforms like GitHub allow using ssh keys for secure authentication when pushing and pulling code.
Automating deployments: Continuous integration and deployment (CI/CD) pipelines can leverage ssh keys for automated deployments to servers.


How to use ssh-key (private and public key)

You don’t need to open or touch “id_rsa” file. You only need to upload your public key “id_rsa.pub” to your server and when ever you use ssh it will automatically use your private key to connect and login to server.


How to upload your ssh public key to Asus Router

An example for using ssh-key is to ssh in to your router to install packages. I have installed “Asuswrt_Merlin” on my Asus AX92U router and used ssh to login and install “Entware” on my router.


How to upload your ssh public key to Asus router

If you are on stock firmware, you can follow this guide. The Asuswrt-Merlin and stock Asuswrt web ui looks almost the same besides Asuswrt-Merlin have added some extra functionalities to web ui. But Adminstration tab is exactly the same on both Merlin and stock firmware.

  1. Open your “id_rsa.pub” file in notepad or any text editor and copy all the texts inside,
  2. Open your router’s web ui and login to your account by opening this link router.asus.com
  3. Find “Authorized Keys” field and paste your public key in text field, to find it:
    1. Open “Administration” tab on left sidebar
    2. Open “System” Tab
    3. Scroll down to find “Authorized Keys” field and paste your public key in the text area
  4. Click on Apply and you are done.

Upload ssh-key to Asus Router




Tags: