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-add
Function.
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-agent
Service, this service is responsible for storing and managing SSH keys.
- Openservice manager: Press
Win + 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-agent
Serve:
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:
-
Open a terminal (Command Prompt or PowerShell).
-
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
)。 -
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-agent
in to automatically use the key for authentication when connecting.
-
Open a terminal (Command Prompt or PowerShell).
-
Enter the following command to load the key:
ssh-add ~/.ssh/id_rsa
so,ssh-agent
Your 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_keys
in the file. You can copy the public key manually, or usessh-copy-id
Tools to accomplish:
-
Copy the public key:
cat ~/.ssh/id_rsa.pub
-
Copy the public key to the remote server's
~/.ssh/authorized_keys
in 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