How to Use SSH in PowerShell

To use SSH in PowerShell, type the same command you’d use on Linux or macOS. Windows ships the OpenSSH client, so this works in both PowerShell 7 and Windows PowerShell 5.1:

ssh alex@web01.example.com

Last week a teammate asked me why he still opened PuTTY to reach a Linux web server. He didn’t need to. This field guide covers the checks, the connection options, the config file, scp, and PowerShell remoting over SSH.

Is SSH built into PowerShell on Windows?

Not into PowerShell itself. SSH comes from the OpenSSH Client, a Windows feature that’s been available since Windows 10 version 1809 and Windows Server 2019. PowerShell just runs ssh.exe like any other program.

Check the version and which file runs. It’s a quick test before you blame the network:

ssh -V
(Get-Command ssh).Source

Output:

OpenSSH_for_Windows_9.5p2, LibreSSL 3.8.2
C:\WINDOWS\System32\OpenSSH\ssh.exe
PowerShell 7 console showing ssh -V with the OpenSSH for Windows version and the ssh.exe path
ssh -V prints the client version, and Get-Command shows where ssh.exe lives (PowerShell 7)

Both shells ran the same file, C:\WINDOWS\System32\OpenSSH\ssh.exe, version 9.5p2. Note that ssh -V writes to the error stream, so capturing it with 2>&1 gives you an ErrorRecord object, not a plain string.

If you installed Git for Windows, it can bring its own ssh.exe. Run where.exe ssh and the first path listed is the one that wins, based on your PATH environment variable.

What else comes with the OpenSSH Client?

The client folder holds more than ssh.exe. Here’s what my Windows 11 PC had:

Get-ChildItem -Path "$env:SystemRoot\System32\OpenSSH" -Filter *.exe |
    Select-Object -ExpandProperty Name

Output:

scp.exe
sftp.exe
ssh-add.exe
ssh-agent.exe
ssh-keygen.exe
ssh-keyscan.exe
ssh-pkcs11-helper.exe
ssh-sk-helper.exe
ssh.exe

You’ll use scp to copy files, ssh-keygen to create keys, and ssh-agent with ssh-add to cache them. The guide to generating SSH keys in PowerShell covers ssh-keygen in depth, so I’ll only touch on keys here.

Check whether the OpenSSH Client is installed

Microsoft’s documented check is Get-WindowsCapability. It’s read-only, but it needs an elevated session, which I tested from a normal account:

try {
    Get-WindowsCapability -Online -ErrorAction Stop |
        Where-Object Name -like 'OpenSSH*' | Select-Object Name, State
}
catch { "Failed. " + $_.Exception.Message }
"Client present: " + (Test-Path "$env:SystemRoot\System32\OpenSSH\ssh.exe")

Output:

Failed. The requested operation requires elevation.

Client present: True

Both PowerShell 7 and 5.1 returned the same elevation error. If you aren’t an admin, the Test-Path line is the practical check: True means ssh.exe is there. The Test-Path cmdlet never needs elevation.

In an elevated window, the same command lists OpenSSH.Client~~~~0.0.1.0 with a State of Installed or NotPresent. If it’s missing, an admin installs it with one line. I didn’t run this, since nothing gets installed on my test PC:

Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0

You can also add