Implement passwordless SSH login on Windows 10
In daily development, SSH (Secure Shell) is widely used as a secure remote login protocol for connections between Linux and Windows systems. To improve efficiency, we can configure passwordless login to save the cumbersome process of entering a password each time we connect.
目录9 个章节
Preface
In daily development, SSH (Secure Shell) is widely used as a secure remote login protocol for connections between Linux and Windows systems. To improve efficiency, we can configure passwordless login to eliminate the cumbersome process of entering a password each time we connect.
This article will detail how to configure SSH passwordless login on Windows 10, similar to the ssh-add functionality on Linux systems.
1. Prerequisites: Ensure OpenSSH is Installed
Before proceeding with the configuration, make sure the OpenSSH client is installed on your Windows 10 system. Let's first check and install OpenSSH:
- Open Settings -> Apps -> Optional Features, and look for OpenSSH Client and OpenSSH Server.
- If not installed, click Add a feature, select OpenSSH Client, and install it.
2. Start the OpenSSH Authentication Agent
To enable passwordless login, we need to start the ssh-agent service, which is responsible for storing and managing SSH keys.
- Open the Services Manager: Press
Win + R, typeservices.msc, and then press Enter. - In the services list, locate OpenSSH Authentication Agent, right-click it, and select Start. Then, set its startup type to Automatic.
Alternatively, you can also start the ssh-agent service via PowerShell:
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 the terminal (Command Prompt or PowerShell).
-
Enter the following command to generate the SSH key:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"Follow the prompts (the default storage path is
~/.ssh/id_rsa). -
Enter the key storage location and passphrase (if you don't want to set a passphrase, you can press Enter to skip).
4. Add SSH Key to ssh-agent
Next, you need to add the generated private key to ssh-agent so that it can 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
This way, ssh-agent will manage your private key, eliminating the need to enter a passphrase every time you connect.
5. Copy Public Key to Remote Server
To allow the remote server to recognize your SSH key, you need to add your public key to the ~/.ssh/authorized_keys file on the server. You can either copy the public key manually or use the ssh-copy-id tool:
-
Copy the public key:
cat ~/.ssh/id_rsa.pub -
Copy the public key to the
~/.ssh/authorized_keysfile on the remote server.
If you use ssh-copy-id, the command is:
ssh-copy-id user@remote_host
6. Testing Passwordless SSH Login
After completing the above configuration, you can try connecting to the remote server:
ssh user@remote_host
If the configuration is successful, you will be able to connect directly without entering a password.
Summary
By following the above steps, you can easily implement passwordless SSH login on Windows 10, similar to ssh-add on Linux. This configuration not only improves connection efficiency but also makes remote management more convenient and secure. If you encounter any issues, refer to the troubleshooting steps provided in this article.
References
- OpenSSH Official Website - https://www.openssh.com/
- Windows 10 OpenSSH Client Documentation - https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse
_EOF_
Implement passwordless SSH login on Windows 10
- 本文作者:
- 程序设计实验室
- 版权声明:
- 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
相关文章
2024年,提升Windows开发和使用体验的一些实践 - 包管理器篇
Windows包管理器?scoop开源自定义,winget官方凑合,WingetUI图形界面总算不用手动折腾了。效率提升?哼,总算不是Linux小众玩家的专利。
2024-02-29 · Windows · 约 1 分钟
Kali-Linux-on-WSL2安装与简单配置指南
Windows在更新到2004版本之后正式开启了WSL2的支持,这次是完整的运行在HyperV虚拟机中的Linux系统了,可以称之为真正的Linux了,难不成Windows即将成为最好的Linux发行版? 实际体验下来还是可以的,不过小问题不少,爱折腾的同学安排一手,对提高Windows平台下的开发体验还是有很大帮助的~ Kali on WSL2安装指南 升级系统 首先检查当前系统版本,按Win+
2021-12-18 · Windows · 约 1 分钟
从SSH远程到Git Push:在Windows上一步到位实现免密码登录
我一直希望在Windows上能像在Linux系统中那样,通过SSH密钥实现免密码远程连接。每次远程连接到服务器时,手动输入密码既麻烦又不太安全,尤其是在我需要频繁操作的情况下。
2025-02-10 · Windows · 约 1 分钟
在Windows上部署OpenSSH服务
Windows终于学会了没羞没臊地用命令行装OpenSSH,结果设置界面还是卡得像屎,算了,至少比以前强点。不过这SSH连上去还是CMD,是哪个脑回路觉得这操作体验没问题啊?
2025-06-12 · Windows · 约 1 分钟
讨论
共 0 条加载评论中…