Installing the Microsoft-provided SSH server software on a Windows 11 system

Learning that lasts. Online courses from $14.99

Microsoft provides Secure Shell (SSH) server software with Windows 11 that you can use to listen for connections from remote SSH clients, but the server service is not installed by default. To install the Microsoft-provided SSH server software on a Windows 11 system, take the following steps:

  1. Type optional features in the Windows Search field at the bottom of the screen and hit Enter, then click on "Open" when it is found.

    Search Optional Features

  2. Click on the View features button.

    Click View Features

  3. Scroll down the list of optional features until you see Open SSH Server and then click on the check box for it and click on the Next button.

    Add an Optional Feature

  4. Click on the Add button to add the OpenSSH Server capability to the system.

    Add OpenSSH Server

  5. When the Optional features window shows that the OpenSSH Server software has been added, you can close the window.

    OpenSSH Server added

    If you scroll down the list of added features before closing the window, you should see OpenSSH Server below OpenSSH Client.

    Added Features

After installing the software, start the OpenSSH server service by taking the following steps:

  1. Type services in the Windows Search" field at the bottom of the screen.

    Search for services

  2. In the Services window, scroll down until you see "OpenSSH SSH Server" and double-click on the service so that you can start the service and change the startup type to automatic, if you wish the service to start whenever Windows boots.

    Services - OpenSSH SSH Server

  3. In the OpenSSH SSH Server properties window, click on the Start button after changing the startup type to automatic, if you wish to have the service run when the system starts.

    Services - start OpenSSH SSH Server

  4. Click on OK. You should then see the status of the service listed as "Running".

    Services - OpenSSH SSH Server running

  5. You can then close the Services window.

If you then open a command prompt window and enter the command netstat -an | find ":22 ", which pipes the output of the netstat command into the find command with the latter command searching for the instance of the default port that SSH servers listen on, i.e., TCP port 22, you should see the following output indicating the system is now listening for incoming SSH connections.

C:\>netstat -an | find ":22 "
  TCP    0.0.0.0:22             0.0.0.0:0              LISTENING
  TCP    [::]:22                [::]:0                 LISTENING

C:\>

The "0.0.0.0:22" indicates the system is listening for TCPv4 connections on that port while the "[::]:22" indicates it is listening for TCPv6 connections on that port.

If you are unsure of whether the Microsoft-provided OpenSSH server software is installed on a system, you can check from a PowerShell prompt run with administrator access — you can open a PowerShell window by typing powershell in the Windows Search window and then clicking on Run as Administrator when it is found.

Run Windows PowerShell

Once the windows is open, enter the command Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*' and hit Enter.

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\windows\system32> Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'


Name  : OpenSSH.Client~~~~0.0.1.0
State : Installed

Name  : OpenSSH.Server~~~~0.0.1.0
State : Installed



PS C:\windows\system32>

When the software is installed and running, you also need to ensure that any firewall software on the system will allow incoming connections to the SSH server on the SSH port. The default firewall software on a Windows system is Microsoft Defender Firewall, but sometimes antivirus software will come with its own firewall software that will be installed as a replacement for Microsoft Defender Firewall. If you took the steps above and the firewall software in use on the system is Microsoft Defender Firewall, the firewall rule needed for inbound connections should be already present.

You can verify that the firewall software is active by running netsh advfirewall show allprofiles state in a command prompt window.

C:\>netsh advfirewall show allprofiles state

Domain Profile Settings:
----------------------------------------------------------------------
State                                 ON

Private Profile Settings:
----------------------------------------------------------------------
State                                 ON

Public Profile Settings:
----------------------------------------------------------------------
State                                 ON
Ok.


C:\>

From the above output, I can see that the Microsoft Defender Firewall is active for all network connections, i.e., for domain, private, and public networks. If I wanted to check the default firewall settings, I could use the command netsh advfirewall show allprofiles firewallpolicy .

C:\>netsh advfirewall show allprofiles firewallpolicy

Domain Profile Settings:
----------------------------------------------------------------------
Firewall Policy                       BlockInbound,AllowOutbound

Private Profile Settings:
----------------------------------------------------------------------
Firewall Policy                       BlockInbound,AllowOutbound

Public Profile Settings:
----------------------------------------------------------------------
Firewall Policy                       BlockInbound,AllowOutbound
Ok.


C:\>

Since the firewall software is enabled and by default will block incoming connections, there will have to be a rule that specifically allows incoming connections to the SSH port, TCP port 22. To verify that one is present specifically for the OpenSSH server software provided by Microsoft, you can use the command netsh advfirewall firewall show rule name="OpenSSH SSH Server (sshd)".

C:\>netsh advfirewall firewall show rule name="OpenSSH SSH Server (sshd)"

Rule Name:                            OpenSSH SSH Server (sshd)
----------------------------------------------------------------------
Enabled:                              Yes
Direction:                            In
Profiles:                             Private
Grouping:                             OpenSSH Server
LocalIP:                              Any
RemoteIP:                             Any
Protocol:                             TCP
LocalPort:                            22
RemotePort:                           Any
Edge traversal:                       No
Action:                               Allow
Ok.


C:\>

From the above output, I can see that inbound connectivity to port 22 is allowed bvy a firewall rule associated with the OpenSSH server software. If you wished to check from a PowerShell window, instead, you could use the command Get-NetFirewallPortFilter | Where-Object { $_.LocalPort -eq 22 } | Get-NetFirewallRule in a PowerShell window.

PS C:\windows\system32> Get-NetFirewallPortFilter | Where-Object { $_.LocalPort -eq 22 } | Get-NetFirewallRule


Name                          : OpenSSH-Server-In-TCP
DisplayName                   : OpenSSH SSH Server (sshd)
Description                   : Inbound rule for OpenSSH SSH Server (sshd)
DisplayGroup                  : OpenSSH Server
Group                         : OpenSSH Server
Enabled                       : True
Profile                       : Private
Platform                      : {}
Direction                     : Inbound
Action                        : Allow
EdgeTraversalPolicy           : Block
LooseSourceMapping            : False
LocalOnlyMapping              : False
Owner                         :
PrimaryStatus                 : OK
Status                        : The rule was parsed successfully from the store. (65536)
EnforcementStatus             : NotApplicable
PolicyStoreSource             : PersistentStore
PolicyStoreSourceType         : Local
RemoteDynamicKeywordAddresses : {}
PolicyAppId                   :
PackageFamilyName             :



PS C:\windows\system32>

The above output shows that inbound connections are allowed, since I see the following:

Direction                     : Inbound
Action                        : Allow

Related:

  1. Modifying an existing Windows Firewall rule
    Date: June 16, 2016
  2. View RDP Firewall Rule using PowerShell
    Date: May 17, 2024

References:

  1. OpenSSH SHH server service doesn't start on Windows 11 computer
    By: Anonymous Date: January 25, 2025
    Microsoft Learn
  2. Open Port in Windows Firewall in Windows 10
    By: Sergey Tkachenko
    Date: September 4, 2018
    Winaero
  3. Installing SFTP/SSH Server on Windows using OpenSSH
    WinSCP