OpenSSH is an ideal and secure way of performing remote maintenance & administration on your servers. Even on Windows Server! :) Microsoft have released their OpenSSH port for Windows Server and Windows 10 back in 2015. Here is how to install the OpenSSH Server on Windows Server 2022, 2019 and 2016.
In this small tutorial, I’m not using PowerShell’s
Add-WindowsCapability cmdlet, because it errors out on unsupported platforms. And I want to be able to customize the sshd installation directory. If you follow this post, you can install Microsoft OpenSSH Server on Windows Server 2022 through even Windows Server 2012 R2, in a folder of your choosing.
In order to be able to install OpenSSH on Windows, you need the software. Doh! :-)
- Download the latest release from GitHub: https://github.com/PowerShell/Win32-OpenSSH/releases (OpenSSH-Win64.zip for example).
Install “Windows for OpenSSH” using PowerShell
- Unblock the downloaded OpenSSH archive if necessary:
- Extract the archive:
Expand-Archive .\Downloads\OpenSSH-Win64.zip -DestinationPath .
- Copy the OpenSSH-Win64 folder to your desired location, e.g c:
Copy-Item -Recurse .\OpenSSH-Win64\ 'C:\'
- The libcrypto.dll file has to be accessible for all users:
&icacls C:\OpenSSH-Win64\libcrypto.dll /grant Everyone:RX
install-sshd.ps1to create the OpenSSH Authentication Agent and OpenSSH SSH Server services. It also sets some permissions and registers an Event Tracing (ETW) provider.
- Change the service startup to Automatic. The OpenSSH SSH Server service is set to Manual startup, not automatic:
&sc.exe config sshd start= auto,
&sc.exe config ssh-agent start= auto
- Start the OpenSSH Authentication Agent and SSH Server services:
&sc.exe start sshd,
&sc.exe start ssh-agent
- Make sure your Windows Defender Firewall is open for port 22, rule OpenSSH-Server-In-TCP must be enabled. If this rule is not available, manually create it:
Code language: PHP (php)
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH SSH Server' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 -Program "C:\Windows\System32\OpenSSH\sshd.exe"
C:\Windows\System32\OpenSSH\sshd.exe with the actual path to the sshd.exe (
C:\OpenSSH\sshd.exe, if you followed this instruction). Or go to Control Panel > System and Security > Windows Firewall > Advanced Settings > Inbound Rules and add a new rule for port 22.
PS C:\> ssh -l janreilink localhost
Install Win32-OpenSSH Server using MSI Installer
If you have downloaded the .msi Windows Installer MSI-file of Microsoft OpenSSH (OpenSSH-Win64-v18.104.22.168.msi), you can install OpenSSH server and client easily. The following command installs both Server and Client:
msiexec /i path to OpenSSH-Win64-v22.214.171.124.msi
This, however installs OpenSSH in the location
C:\Program Files\OpenSSH, and doesn’t update your
$env:path environment variable and there are some other caveats. You can follow my guide “install Microsoft OpenSSH Client properly in Windows 11 and Windows 10 to support FIDO/U2F security keys” on Windows Server 2022 / 2019 to install and configure OpenSSH Server and Client using .msi installer files.
Often you not only need to install OpenSSH, you also need to configure it. For this, OpenSSH on Windows uses an mechanism where the default
sshd_config (called “
sshd_config_default“) is located in the directory to where you’ve unpacked the
OpenSSH-Win64.zip archive. When you start the service, the file is copied to
In Windows, sshd reads configuration data from %programdata%\ssh\sshd_config by default, or a different configuration file may be specified by launching sshd.exe with the -f parameter. If the file is absent, sshd generates one with the default configuration when the service is started.https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_server_configuration#windows-configurations-in-sshd_config
So you can either make you configuration in the
sshd_config_default file, that is copied when you start the service for the first time, or you start and stop OpenSSH, edit
C:\ProgramData\ssh\sshd_config and restart OpenSSH again.
Older Windows Server versions: Install OpenSSH on Windows Server 2012
OpenSSH Server on Windows Server 2012 R2, you said? Yes, you can use the same method to install OpenSSH in Windows Server 2012 R2 (version 6.3.9600). Here is a screenshot of connecting to sshd on Windows version 6.3.9600:
Conclusion and giveaway
In this post I showed you how you can install OpenSSH server in various Windows Server versions, using the downloaded .zip file archive and PowerShell. You can use this approach to customize and streamline your Microsoft OpenSSH Server environment. This goes very well with SSH keys stored in Active Directory. If you want to use FIFO/U2F security keys like YubiKey in Windows OpenSSH, follow that guide.
In an other post I’ll show you how to install OpenSSH Client in Windows 11 and Windows 10. Using the OpenSSH-Win64-v126.96.36.199.msi file.
More OpenSSH in Windows Server and Windows 11 / Windows 10, the series
Here on Sysadmins of the North are more posts in a series of posts about OpenSSH in Windows. Whether it’s Windows Server or Windows 11 / 10. You may find these posts interesting:
- Tunnel RDP through SSH & PuTTY
- How to share OpenSSH keys with WSL in Windows 10
- Manually install OpenSSH in Windows Server
- Retrieve SSH public key from Active Directory for SSH authentication
- Windows 11/10 and WSL 2 DevOps environment
- YubiKey support in OpenSSH for Windows 11 and Windows 10
- Connect to a KVM host through an ssh tunnel and arbitrary port in Windows 11 and WSL 2
I hope you like it, let me know.