Enable OpenSSH Server and client feature in Windows 11 or 10 using the PowerShell command line or Terminal…
Microsoft has changed a couple of things with the advancement of Windows 10 which also shows its proliferating love towards the Open source and Linux. That’s is the reason we can see the WSL & OpenSSH integration in Windows 10 as well as in its successor OS Windows 11.
Well, on one hand, the OpenSSH client will be installed and activated by default on Windows 11, Server part of this SSH program needs to be set up manually. And here we are with a tutorial to learn that.
Command to install OpenSSH Server and client in Windows 11 or 10
The SSH client on Windows 10/11 is installed in the so-called optional features. This can be reached by searching for “optional features” in the start menu. The SSH client can be found under “Add feature”. However, we will go for the Command line method to set up SSH.
Open PowerShell Command line
Whether you are on Windows 10 or 11, right-click on the Start button and select either Windows Terminal (Admin) or PowerShell (Admin)
Check SSH server & client are active or not
To know whether OpenSSH is already installed on your Windows system or not, run the following command:
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
In our case, the client was installed but the OpenSSH server was not. If that is the same then move to the next step.
Install OpenSSH Server on Windows 11 or 10
We have given both the commands to activate either the Client or Server part of this open-source SSH tool.
# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start OpenSSH Server Service
To make the service of OpenSSH start and run automatically with the system boot use the below-given commands:
Start-Service sshd
Mark the service to start automatically:
Set-Service -Name sshd -StartupType 'Automatic'
Configure SSH in Firewall
Paste the given block of command in the Powershell and hit the Enter key. Although the Firewall rule will automatically get configured while installing the OpenSSH server, however still to confirm it run the given command. If the Firewall rule already exits then you will have “Firewall rule ‘OpenSSH-Server-In-TCP’ has been created and exists” in return.
if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) { Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..." New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 } else { Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists." }
Connect to OpenSSH Server
Now, we can test our server by connecting it using some other computer or virtual machine. Simply open the command line of Linux, macOS, or Windows that can access the installed SSH server’s IP address and use the following given syntax to connect the same.
ssh [email protected]/servername
For example:
ssh [email protected] 192.168.43.252
Here we are using Ubuntu Linux to connect the Windows command line via SSH server.
Remove or Uninstall
In case you want to disable or uninstall the OpenSSH server/client feature on Windows 10 or 11, here are the commands to follow. Again open Powershell as Admin and run the following desired one.
#Remove the OpenSSH Client
Remove-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
#Remove the OpenSSH Server
Remove-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Related Posts
Install and Use OpenSSH server on Windows 11 or 10
Install & Use SSH under Windows 11 to connect remote server
MobaXterm ssh client, the best alternative to Putty free & open-source tool
How to install MobaXterm Terminal using Chocolaty on Windows 10/7
How to install MobaXterm on a Windows computer? A beginner’s guide
How to connect Elastic Beanstalk instance via SSH