Location>code7788 >text

Password-free SSH login on Windows 10

Popularity:938 ℃/2025-01-17 11:52:18

Preface

In daily development, SSH (Secure Shell), as a secure remote login protocol, is widely used for connections between Linux and Windows systems. In order to improve efficiency, we can configure password-free login to save the tedious process of entering a password every time we connect.

This article will detail how to configure SSH password-free login on Windows 10, similar to that on Linux systemsssh-addFunction.

1. Preparation: Make sure OpenSSH is installed

Before starting the configuration, make sure you have the OpenSSH client installed on your Windows 10. Here we first check and install OpenSSH:

  • Openset up -> application -> Optional features, find if there isOpenSSH clientandOpenSSH service
  • If it is not installed, clickAdd functionality,chooseOpenSSH clientto install.

2. Start OpenSSH Authentication Agent

To achieve password-free login, we need to enablessh-agentService, this service is responsible for storing and managing SSH keys.

  • Openservice manager: PressWin + R,enter, and then press Enter.
  • Found in service listOpenSSH Authentication Agent, right-click and selectstart up, and then set the startup type toautomatic

Alternatively, you can launch it via PowerShellssh-agentServe:

Start-Service ssh-agent
Set-Service -Name ssh-agent -StartupType Automatic

3. Generate SSH key pair

If you haven't generated an SSH key yet, you can create one by following these steps:

  1. Open a terminal (Command Prompt or PowerShell).

  2. Enter the following command to generate an SSH key:

    ssh-keygen -t rsa -b 4096 -C "your_email@"
    

    Follow the prompts (the default storage path is~/.ssh/id_rsa)。

  3. Enter the key storage location and password (if you don’t want to set a password, you can just press Enter to skip it).

4. Add SSH keys to ssh-agent

Next, the generated private key needs to be added tossh-agentin to automatically use the key for authentication when connecting.

  1. Open a terminal (Command Prompt or PowerShell).

  2. Enter the following command to load the key:

    ssh-add ~/.ssh/id_rsa
    

so,ssh-agentYour private key will be managed, eliminating the need to enter a password each time you connect.

5. Copy the public key to the remote server

In order for the remote server to recognize your SSH key, you need to add the public key to the server's~/.ssh/authorized_keysin the file. You can copy the public key manually, or usessh-copy-idTools to accomplish:

  1. Copy the public key:

    cat ~/.ssh/id_rsa.pub
    
  2. Copy the public key to the remote server's~/.ssh/authorized_keysin the file.

If you usessh-copy-id, the command is as follows:

ssh-copy-id user@remote_host

6. Test password-free SSH login

After completing the above configuration, you can try to connect to the remote server:

ssh user@remote_host

If the configuration is successful, you will be able to connect directly without entering a password.

Summarize

Through the above steps, you can easily implement the password-free SSH login function on Windows 10, similar to that on Linuxssh-add. This configuration not only improves connection efficiency, but also makes remote management more convenient and secure. If you encounter any problems, you can refer to the solution steps in this article to troubleshoot.

References

  • OpenSSH official website -/
  • Windows 10 OpenSSH Client Documentation -/en-us/windows-server/administration/openssh/openssh_install_firstuse