How to install OpenSSH Server in Windows Server using PowerShell

Follow below steps to install OpenSSH Server in Windows Server using PowerShell.

Step 1 - Open Windows PowerShell from Windows Startmenu, by right-clicking it and selecting "Run as administrator". Run cmdlet Get-WindowsCapability, as shown below, to know the Windows OS capabilities related with SSH. We can see from the output that the OpenSSH client is installed and OpenSSH server is not installed, as shown below.


Step 2 - To install OpenSSH SSH Server using PowerShell, run Add-WindowsCapability cmdlet as shown below.


Step 3 - To start OpenSSH SSH Server service, run Start-Service PowerShell cmdlet, as shown below.


Step 4 - If you want OpenSSH SSH Server service to start automatically every time Windows Server Operating System starts, set OpenSSH SSH Server service Startup type as "Automatic", as shown below.


Step 5 - Create a Windows Firewall rule for sshd to allow inbound TCP connections to Port number 22, where SSH server listens by default. Use NewNetFirewallRule PowerShell cmdlet, as shown below.

 New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22


Step 6 - Finally, to view the Windows Firewall rule for sshd, run PowerShell cmdlet Get-NetFirewallRule as shown below.


Related Tutorials
What is SSH (Secure Shell)
History of SSH protocol
What SSH can do
Versions of SSH Protocol
RFCs related with SSH protocol
SSH Protocols and Products
SSH Client and SSH Server
SSH Components
SSH Packet Format
SSH Encryption Algorithms
Hash values, MAC and HMAC in SSH
What is SSH host key
How SSH works
How to install OpenSSH server in Windows Server
How to start OpenSSH Service in Windows Server
How to configure SSH server in Cisco Router
PuTTY login to Cisco Router using SSH protocol
How to install OpenSSH client in Windows 10
Port forwarding using SSH
How to configure SSH port forwarding