-
Notifications
You must be signed in to change notification settings - Fork 39
Install OpenSSH in Windows
These steps will help you install and enable the ssh-agent service on Windows to allow SSH agent forwarding into development containers.
The latest beta versions of OpenSSH must be used due to an issue with development containers.
To install the latest OpenSSH version (v9.5.0.0p1-Beta as of this writing).
- Download the latest OpenSSH
.msiinstaller. - Run the following in an elevated PowerShell (run as administrator):
# Install just the client (ssh-agent)
msiexec /i <path to openssh.msi> ADDLOCAL=Client
# Add the ssh commands to the PATH
[Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path",[System.EnvironmentVariableTarget]::Machine) + ';' + ${Env:ProgramFiles} + '\OpenSSH', [System.EnvironmentVariableTarget]::Machine)
# Check that the ssh-agent service is running
Get-Service -Name ssh-agent
# Now load your key files into ssh-agent
ssh-add $env:USERPROFILE\.ssh\id_ed25519
# This should show your key is loaded in the agent
ssh-add -lFull installation instructions can be found here.
.msi above.
This official page outlines the steps to install OpenSSH: Key-based authentication in OpenSSH for Windows
The document above describes how to install both the client (ssh-agent) and the server (sshd). We only need the client, so the minimal PowerShell steps are (run as administrator):
# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
# By default the ssh-agent service is disabled. Configure it to start automatically.
# Make sure you're running as an Administrator.
Get-Service ssh-agent | Set-Service -StartupType Automatic
# Start the service
Start-Service ssh-agent
# This should return a status of Running
Get-Service ssh-agent
# Now load your key files into ssh-agent
ssh-add $env:USERPROFILE\.ssh\id_ed25519
# This should show your key is loaded in the agent
ssh-add -lReplace id_ed25519 with the name of your private key file if it differs.