Windows 2025
Sponsored Link

OpenSSH : Use SSH-Agent2024/11/27

 

Use SSH-Agent to automate inputting passphrase on key-pair authentication.

[1] SSH-Agent is installed by default with OpenSSH Client programs, however, it is disabled by default, so turn to enabled and also Start the service.
PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Users\Administrator> Get-Service ssh-agent 

Status   Name               DisplayName
------   ----               -----------
Stopped  ssh-agent          OpenSSH Authentication Agent

# set [Automatic] for Startup
PS C:\Users\Administrator> Set-Service -Name "ssh-agent" -StartupType Automatic 

# start service
PS C:\Users\Administrator> Start-Service -Name "ssh-agent" 
[2] Logon as a user that you set SSH key-pair, and add secret key like follows.
PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

# add passphrase
PS C:\Users\serverworld> ssh-add '.ssh\id_ed25519' 
Enter passphrase for .ssh\id_ed25519:
Identity added: .ssh\id_ed25519 (serverworld@RX-7)

# verify
PS C:\Users\serverworld> ssh-add -l 
256 SHA256:w+aQ2I73DzLn6WhOlIwJ8+DVcG2hpcAARnqSmdTTcBI serverworld@RX-7 (ED25519)

# try to conenct wuthout inputting passphrase
PS C:\Users\serverworld> ssh Serverworld@10.0.0.101 

Microsoft Windows [Version 10.0.26100.2314]
(c) Microsoft Corporation. All rights reserved.

serverworld@RX-7 C:\Users\serverworld> 
serverworld@RX-7 C:\Users\serverworld> exit 


# remove all identities
# if remove a specific identity, specify [-d] option
PS C:\Users\serverworld> ssh-add -D 
All identities removed.
Matched Content