Skip to content

Install OpenSSH in Windows

Zarillion edited this page Jun 5, 2024 · 2 revisions

These steps will help you install and enable the ssh-agent service on Windows to allow SSH agent forwarding into development containers.

Install OpenSSH via MSI

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

  1. Download the latest OpenSSH .msi installer.
  2. 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 -l

Full installation instructions can be found here.

Install OpenSSH via PowerShell

⚠️ Do not use these steps. They install an older version of OpenSSH that does not work with devcontainers. I am leaving these steps here in case we can transition to using them instead of the .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 -l

Replace id_ed25519 with the name of your private key file if it differs.

Clone this wiki locally