SSH is a secure and convenient way to connect to a remote machine from another computer. On Windows, Microsoft provides OpenSSH Server as a built-in optional feature, which allows administrators to manage Windows systems remotely using standard SSH tools.
This guide explains how to install, enable, and test OpenSSH Server on Windows using PowerShell.
Requirements
Before you begin, make sure that:
- You are using Windows 10, Windows 11, Windows Server 2019, Windows Server 2022, or Windows Server 2025.
- You have administrator access.
- PowerShell is running as Administrator.
- The server has access to Windows Update, unless OpenSSH Server is already installed.
Step 1: Open PowerShell as Administrator
Click Start, search for PowerShell, right-click it, and select Run as administrator.
All commands below should be executed from an elevated PowerShell window.
Step 2: Check Whether OpenSSH Server Is Installed
Run the following command:
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
You may see output similar to this:
Name : OpenSSH.Client~~~~0.0.1.0
State : Installed
Name : OpenSSH.Server~~~~0.0.1.0
State : NotPresent
If OpenSSH.Server shows NotPresent, it needs to be installed.
Step 3: Install OpenSSH Server
To install the SSH server, run:
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Wait until the installation is completed.
You can verify the installation again:
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
The server should now show:
State : Installed
Step 4: Start the SSH Server Service
After installation, start the SSH server service:
Start-Service sshd
Then check the service status:
Get-Service sshd
If everything is working correctly, the service status should be:
Running
Step 5: Enable SSH Server on System Startup
To make sure the SSH server starts automatically after every reboot, run:
Set-Service -Name sshd -StartupType Automatic
This ensures that SSH access remains available even after the server restarts.
Step 6: Allow SSH Through Windows Firewall
By default, SSH uses TCP port 22.
Run the following command to allow incoming SSH connections:
if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue)) {
New-NetFirewallRule `
-Name "OpenSSH-Server-In-TCP" `
-DisplayName "OpenSSH Server (sshd)" `
-Enabled True `
-Direction Inbound `
-Protocol TCP `
-Action Allow `
-LocalPort 22
}
This creates a firewall rule that allows incoming SSH connections on port 22.
Step 7: Find the Windows Server IP Address
To connect to the Windows machine remotely, you need to know its IP address.
Run:
ipconfig
Find the active network adapter and copy the IPv4 address.
Example:
IPv4 Address . . . . . . . . . . : 192.168.1.50
Step 8: Connect to Windows Using SSH
From another Windows, Linux, or macOS machine, use the following command:
ssh username@server-ip-address
Example:
ssh [email protected]
Replace Administrator with your Windows username and replace 192.168.1.50 with the real IP address of the server.
If this is your first connection, you may be asked to confirm the server fingerprint.
Type:
yes
Then enter the Windows user password.
Step 9: Test That SSH Works Correctly
After logging in, you should see a Windows command prompt or PowerShell session.
You can test the connection by running:
hostname
whoami
If these commands return the server name and your Windows username, SSH access is working correctly.
Optional: Change the Default SSH Shell to PowerShell
By default, SSH may open a Command Prompt session.
If you want SSH users to get PowerShell by default, run:
New-ItemProperty `
-Path "HKLM:\SOFTWARE\OpenSSH" `
-Name DefaultShell `
-Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" `
-PropertyType String `
-Force
After that, restart the SSH service:
Restart-Service sshd
The next SSH login should open PowerShell by default.
Useful Service Commands
Start SSH server:
Start-Service sshd
Stop SSH server:
Stop-Service sshd
Restart SSH server:
Restart-Service sshd
Check SSH server status:
Get-Service sshd
Enable SSH server on startup:
Set-Service -Name sshd -StartupType Automatic
Troubleshooting
If you cannot connect to the server, check the following:
Check that the SSH service is running
Get-Service sshd
Check that port 22 is open in Windows Firewall
Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP"
Restart the SSH service
Restart-Service sshd
Check the server IP address
ipconfig
Check common connection issues
Make sure that:
- You are using the correct username.
- You are using the correct password.
- The server IP address is correct.
- TCP port
22is not blocked by Windows Firewall. - TCP port
22is not blocked by an external firewall or hosting provider firewall. - The
sshdservice is running.
Conclusion
OpenSSH Server is a simple and reliable way to manage Windows remotely.
After installation, you only need to:
- Install OpenSSH Server.
- Start the
sshdservice. - Enable the service on startup.
- Allow TCP port
22in Windows Firewall. - Connect using an SSH client.
Once configured, you can connect to the Windows machine from any SSH client using:
ssh username@server-ip-address
This makes Windows administration easier, especially for remote servers and automated management tasks.