Skip to content

Install and Scope OpenSSH Server on Windows

Admin
October 4, 2026
7 min read
Intermediate
💻 Target OS: Windows Server 2025 / 2022

Before you begin

  • Applies to:OpenSSH Server on supported Windows client and Windows Server releases.
  • Where to start:Open elevated PowerShell on the target Windows host. Use a separate approved client for the connection test.
  • What you need:Have a dedicated administrative account, an approved management subnet, and the authentication method required by your organization.
Guide tools
Guide tools
0/0 Steps (0%)

Windows OpenSSH Server provides SSH-based remote administration alongside Windows’ other management options. This tutorial installs the optional capability, starts the sshd service, narrows its inbound firewall rule to an approved management subnet, and verifies access from an authorized client.

Run the setup in an elevated PowerShell session on a supported Windows client or Server release. Use a dedicated administrative account, prefer key-based authentication according to your organization’s policy, and avoid exposing SSH to the public Internet without a reviewed access design.


01

Confirm the Capability State Before Installing

Installation

Check whether OpenSSH Server is already installed. If it is absent, install the server capability; do not install the client capability unless this computer also needs to initiate SSH sessions.

Terminal window
$CapabilityName = 'OpenSSH.Server~~~~0.0.1.0'
$Capability = Get-WindowsCapability -Online -Name $CapabilityName -ErrorAction Stop
if ($Capability.State -ne 'Installed') {
Add-WindowsCapability -Online -Name $CapabilityName -ErrorAction Stop | Out-Null
}
$Capability = Get-WindowsCapability -Online -Name $CapabilityName -ErrorAction Stop
if ($Capability.State -ne 'Installed') { throw 'OpenSSH Server did not reach the Installed state.' }
$Capability | Select-Object Name, State
❯ Illustrative Output (Results Vary)
Name : OpenSSH.Server~~~~0.0.1.0
State : Installed

02

Set the Service to Start Automatically

Service Setup

Start the SSH service and configure automatic startup if this host is intended to accept SSH after reboot. Windows setup may create a default inbound firewall rule; inspect it before enabling remote access.

Terminal window
Set-Service -Name sshd -StartupType Automatic
Start-Service -Name sshd -ErrorAction Stop
$SshService = Get-Service -Name sshd -ErrorAction Stop
if ($SshService.Status -ne 'Running') { throw 'The sshd service did not reach the Running state.' }
$SshService
Get-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -ErrorAction SilentlyContinue |
Select-Object Name, Enabled, Profile, Direction, Action
❯ Illustrative Output (Results Vary)
Status Name DisplayName
------ ---- -----------
Running sshd OpenSSH SSH Server

03

Replace the Broad Rule Scope with an Approved Subnet

Firewall Scope

If the default rule exists, restrict its remote addresses to your trusted management subnet. The example uses 10.20.30.0/24; substitute the actual range and choose the profile that applies to this host’s management network. A workgroup server commonly uses Private rather than Domain. If there is no rule, create one with a scoped address filter instead of allowing any source. Also inspect other effective inbound allow rules for TCP 22: this scoped rule does not narrow a separate, broader allow rule.

Terminal window
$ManagementSubnet = '10.20.30.0/24'
# Use the profile that applies to the management interface.
# For a domain-connected interface use Domain; a workgroup may use Private.
$FirewallProfile = 'Domain'
$FirewallProfile
$SshRule = Get-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -ErrorAction SilentlyContinue
if ($SshRule) {
$SshRule | Set-NetFirewallRule -Enabled True -Profile $FirewallProfile
$SshRule | Get-NetFirewallAddressFilter |
Set-NetFirewallAddressFilter -RemoteAddress $ManagementSubnet
} else {
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP-Scoped' `
-DisplayName 'OpenSSH Server - Management Subnet Only' `
-Enabled True -Direction Inbound -Protocol TCP -LocalPort 22 `
-RemoteAddress $ManagementSubnet -Profile $FirewallProfile -Action Allow
}
Get-NetFirewallRule -Name 'OpenSSH-Server-In-TCP*' |
Get-NetFirewallAddressFilter
❯ Illustrative Output (Results Vary)
RemoteAddress : 10.20.30.0/24

04

Verify the Listener and User Login

Verification

Confirm the service is listening on TCP port 22, then connect from a client in the permitted subnet. Check the server’s OpenSSH configuration under C:\ProgramData\ssh\sshd_config if authentication or the default shell does not behave as expected.

Terminal window
Get-NetTCPConnection -State Listen -LocalPort 22
Terminal window
❯ Illustrative Output (Results Vary)
The SSH client prompts for the configured authentication method and opens a Windows shell after successful authentication.
PowerShell showing the OpenSSH service running, its scoped firewall address, and a listening port 22

Figure 1: The Windows SSH service is running, its firewall rule is scoped to the management subnet, and port 22 is listening.

See Microsoft’s OpenSSH first-use guide and server configuration guide for supported settings.

Comments