曦远 (DealiAxy)一份私人的文字刊物

StarBlog
返回文章列表折页手记阅读全文
Windows

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.

曦远 (DealiAxy)约 10 分钟
目录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, type services.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:

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

  2. 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).

  3. 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.

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

  2. 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:

  1. Copy the public key:

    cat ~/.ssh/id_rsa.pub
    
  2. Copy the public key to the ~/.ssh/authorized_keys file 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

_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 分钟

Windows设置Pageant开机自动启动并且加载秘钥

场景 用Linux的时候ssh和git这些很方便,因为只要一次ssh-add就可以一劳永逸,以后需要认证的时候ssh-agent会帮我们搞定,不需要输入秘钥的密码。 其实Windows也可以实现这种生产力解放,就是用putty附带的工具里的Pageant。 Pageant主要负责和服务器端进行身份验证,但是每次在启动Pageant后都需要手动的加载秘钥文件,本文就是要介绍让Pageant开机自动加

2021-12-18 · Windows · 约 1 分钟

讨论

共 0 条

良言一句三冬暖,恶语伤人六月寒。

加载评论中…