
Windows Server includes Microsoft's port of OpenSSH, so you can manage a Windows server over SSH, transfer files with SFTP and SCP, and automate tasks from Linux or macOS machines just as you would with a Linux server. This guide shows how to install and enable OpenSSH Server on Windows Server 2019 and 2022 with Settings or PowerShell, what is different on Windows Server 2025, how to open the firewall, set PowerShell as the default shell, use SSH keys correctly for administrator accounts, and troubleshoot.
Quick answerOpen PowerShell as administrator and run:
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd
Set-Service -Name sshd -StartupType Automatic
Then connect from another computer with ssh Administrator@your-server-ip.
Check whether OpenSSH is already installed
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
The output shows OpenSSH.Client and OpenSSH.Server with a state of Installed or NotPresent. The client is usually installed already; the server usually is not on 2019 and 2022.
Windows Server 2025 includes OpenSSH Server by default; you only need to enable it, either from Server Manager → Local Server → Remote SSH Access or by starting the sshd service as shown below.
Method 1: Install with Settings (GUI)
- Open Settings → Apps → Apps & features → Optional features (on Server 2022, Settings → Apps → Optional features).
- Click Add a feature.
- Find OpenSSH Server, select it and click Install.
- When it finishes, continue with the service and firewall steps below.
Method 2: Install with PowerShell
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
The installation downloads the feature from Windows Update. On servers that use WSUS or have no internet access, this can fail; in that case, install it from the Features on Demand media for your Windows Server version, or ask your administrator to allow optional features from Windows Update.
Step 3: Start the service and set it to start automatically
Start-Service sshd
Set-Service -Name sshd -StartupType Automatic
Get-Service sshd
Starting the service for the first time also generates the server's host keys in C:\ProgramData\ssh.
Step 4: Check the firewall rule
Installation normally creates an inbound rule named OpenSSH-Server-In-TCP for port 22. Confirm it, or create it if it is missing:
Get-NetFirewallRule -Name OpenSSH-Server-In-TCP
New-NetFirewallRule -Name OpenSSH-Server-In-TCP -DisplayName "OpenSSH Server (sshd)" `
-Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
On a cloud server, also allow port 22 in the provider's firewall. Restrict it to your IP addresses where possible.
Step 5: Connect
From Windows 10/11, Linux or macOS:
ssh Administrator@203.0.113.10
ssh DOMAIN\\user@203.0.113.10 # domain account (or user@domain.local)
The default shell is Command Prompt. Copy files with scp or sftp, or use WinSCP or FileZilla with the SFTP protocol.
Set PowerShell as the default shell
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell `
-Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force
If you have installed PowerShell 7, point it to C:\Program Files\PowerShell\7\pwsh.exe instead. New SSH sessions open in PowerShell.
Use SSH keys (and the administrator gotcha)
- On your computer, create a key pair:
ssh-keygen -t ed25519. - For a standard user, put the public key in
C:\Users\username\.ssh\authorized_keyson the server. - For a user in the Administrators group, OpenSSH on Windows ignores that file by default. Put the key in
C:\ProgramData\ssh\administrators_authorized_keysinstead, and fix its permissions:
icacls.exe "C:\ProgramData\ssh\administrators_authorized_keys" /inheritance:r /grant "Administrators:F" /grant "SYSTEM:F"
Once key login works, you can disable password logins by setting PasswordAuthentication no in C:\ProgramData\ssh\sshd_config and restarting the service with Restart-Service sshd.
Change the SSH port
Edit C:\ProgramData\ssh\sshd_config, change #Port 22 to, for example, Port 2222, add a firewall rule for the new port, then Restart-Service sshd. Connect with ssh -p 2222 user@server.
Troubleshooting
- Connection refused or timed out: check
Get-Service sshdis running, the firewall rule exists, and the provider firewall allows the port. - Key login ignored for an admin account: use
administrators_authorized_keyswith the permissions shown above. - Add-WindowsCapability fails: the server cannot reach Windows Update for optional features; use the Features on Demand media.
- Logs: open Event Viewer → Applications and Services Logs → OpenSSH → Operational.
Frequently asked questions
Does Windows Server have SSH built in?
Yes. OpenSSH is an optional feature on Windows Server 2019 and 2022, and is included by default on Windows Server 2025.
What port does OpenSSH use on Windows?
Port 22 by default. You can change it in C:\ProgramData\ssh\sshd_config.
Can I use SFTP with Windows Server?
Yes. Once OpenSSH Server is running, SFTP and SCP work automatically with any SFTP client.
Should I use SSH or RDP to manage Windows Server?
Use RDP for graphical tools and SSH for command-line administration, automation and file transfers. Many administrators use both.


