返回文章列表文章索引阅读全文
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 许可协议。转载请注明出处!

相关文章

讨论

共 0 条

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

加载评论中…