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 许可协议。转载请注明出处!
相关文章
Kali-Linux-on-WSL2安装与简单配置指南
Windows在更新到2004版本之后正式开启了WSL2的支持,这次是完整的运行在HyperV虚拟机中的Linux系统了,可以称之为真正的Linux了,难不成Windows即将成为最好的Linux发行版? 实际体验下来还是可以的,不过小问题不少,爱折腾的同学安排一手,对提高Windows平台下的开发体验还是有很大帮助的~ Kali on WSL2安装指南 升级系统 首先检查当前系统版本,按Win+
2021-12-18 · Windows · 约 1 分钟
WSL小技巧:切换到zsh以及加入右键菜单
切换到zsh 说明 在 Windows Subsystem for Linux 中,执行 chsh -s /bin/zsh 并不能成功地将默认 shell 修改为 zsh。在打开 WSL 时,默认 shell 仍然为 bash。 这是因为WSL 在启动时并没有执行 login 相关的组件,而这些组件和默认 shell 有关。Microsoft 已经知晓了这个问题,但并没有计划去解决。 方法 我们可
2021-12-18 · Windows · 约 1 分钟
Windows设置Pageant开机自动启动并且加载秘钥
场景 用Linux的时候ssh和git这些很方便,因为只要一次ssh-add就可以一劳永逸,以后需要认证的时候ssh-agent会帮我们搞定,不需要输入秘钥的密码。 其实Windows也可以实现这种生产力解放,就是用putty附带的工具里的Pageant。 Pageant主要负责和服务器端进行身份验证,但是每次在启动Pageant后都需要手动的加载秘钥文件,本文就是要介绍让Pageant开机自动加
2021-12-18 · Windows · 约 1 分钟
修复winget命令找不到的问题
微软官方包管理器winget在Windows 10 1809以上版本中,用于快速安装、更新和管理应用程序。本文介绍了因系统环境变化导致winget命令失效的问题,分析了可能原因,并提供了解决方案及预防措施,包括修复命令、定期更新检查、备份环境变量等。
2025-04-04 · Windows · 约 1 分钟
讨论
共 0 条加载评论中…