CodeBrowser

How to SSH Into a Windows Machine

Windows 10 and 11 include a built-in OpenSSH server, so you can SSH into a Windows PC from a Mac, Linux box or another Windows machine just like a Linux server. Here’s how to turn it on, connect, use PowerShell and set up key login.

Windows 10 & 11Windows ServerPowerShell commandsSSH key login

The basics

Can you SSH into Windows?

Yes. Microsoft ships the same OpenSSH used on Linux as an optional Windows feature called OpenSSH Server. Once it’s installed and running, any SSH client can connect to the PC and get a command prompt or PowerShell session.

It works on Windows 10 (version 1809 and later) and Windows 11, including Home editions, and on Windows Server 2019 and later.

Using Windows Server 2025?

OpenSSH Server is already installed on Windows Server 2025, but turned off. Skip step 1 and enable it in Server Manager, or start the service with the PowerShell commands in step 2. By default it only accepts connections on private networks.

Step 1

Install OpenSSH Server on Windows

Option A: Settings

  1. Windows 11: open Settings → System → Optional features and click View features.
  2. Windows 10: open Settings → Apps → Optional features and click Add a feature.
  3. Search for OpenSSH Server, tick it and click Install (Windows 11: Next, then Install).

Option B: PowerShell

Right-click Start, choose Terminal (Admin) or Windows PowerShell (Admin), and run:

Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

Check it worked with Get-WindowsCapability -Online -Name OpenSSH.Server*. The State should say Installed.

Step 2

Start the SSH service and open the firewall

In the same admin PowerShell window, start the SSH server and make it start automatically with Windows:

Start the SSH server now

Start-Service sshd

Start it automatically at boot

Set-Service -Name sshd -StartupType 'Automatic'

Installing OpenSSH Server normally adds a firewall rule for port 22. Check that it exists with Get-NetFirewallRule -Name *ssh*. If nothing is listed, add it:

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

Steps 3 and 4

Find the PC’s address and username, then connect

Find the IP address

On the Windows PC, run ipconfig and look for the IPv4 Address, like 192.168.1.50. You can also use the PC’s name.

Find the username

Run whoami. You’ll see pcname\username; use the part after the backslash.

Connect

From the other computer, run ssh username@192.168.1.50, type yes to trust the PC, then enter the Windows password.

Signed in with a Microsoft account? Your SSH username is still the local one from whoami (often the first letters of your name), but the password is your Microsoft account password. On a work domain, use ssh domain\username@pcname or ssh username@domain@pcname.

Optional

Use PowerShell instead of Command Prompt

By default, SSH sessions on Windows open the old Command Prompt (cmd.exe). To get PowerShell instead, run this once in an admin PowerShell window on the PC you’re connecting to:

New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force

New SSH sessions now open in PowerShell. Existing sessions keep their old shell until you reconnect.

Where the settings live

  • Server config: C:\ProgramData\ssh\sshd_config
  • Logs: Event Viewer → Applications and Services Logs → OpenSSH
  • Apply changes: Restart-Service sshd

Edit sshd_config as an administrator, the same way you would on Linux, for example to change the port or turn off password logins.

SSH keys

Set up SSH key login to Windows

Key login works on Windows too, with one twist: where the public key goes depends on whether the Windows account is an administrator. Need a key first? Create one with ssh-keygen -t ed25519 or our SSH Key Generator.

Standard user accounts

Paste your public key on its own line in this file on the Windows PC, creating the folder and file if needed:

C:\Users\username\.ssh\authorized_keys

Administrator accounts

Windows ignores the file above for admins. Put the key in this shared file instead, then lock its permissions:

C:\ProgramData\ssh\administrators_authorized_keys

icacls.exe "C:\ProgramData\ssh\administrators_authorized_keys" /inheritance:r /grant "Administrators:F" /grant "SYSTEM:F"

Then connect as usual. If Windows still asks for a password, the key is in the wrong file or the permissions are too open. The OpenSSH event log will tell you which.

Troubleshooting

Can’t SSH into Windows? Common fixes

ProblemFix
Connection refusedThe SSH server isn’t running. Run Get-Service sshd on the PC and start it with Start-Service sshd.
Connection timed outThe firewall is blocking port 22, or you have the wrong IP. Check the firewall rule from step 2, and that both computers are on the same network.
Permission denied with the right passwordUse the local username from whoami, not your email address. For Microsoft accounts, use your Microsoft account password.
Key login is ignored for an admin accountAdmins must use C:\ProgramData\ssh\administrators_authorized_keys with the permissions shown above.
OpenSSH Server won’t installThe PC may be blocked from Windows Update by company policy. Ask your IT team, or install it from an offline Features on Demand source.

FAQ

SSH into Windows questions, answered

Does Windows Home support an SSH server?

Yes. OpenSSH Server is an optional feature on Windows 10 and 11 Home as well as Pro, Enterprise and Education.

Can I SSH into Windows from a Mac or Linux?

Yes. Once OpenSSH Server is running on the Windows PC, connect from Terminal on a Mac or Linux machine with ssh username@pc-ip-address, exactly as you would to a Linux server.

Can I SSH into my Windows PC from outside my home network?

You can, but opening port 22 to the internet invites constant login attempts. A safer option is a private VPN such as WireGuard or Tailscale, so the PC is only reachable from your own devices.

Can I copy files to Windows over SSH?

Yes. scp, sftp and SFTP apps like WinSCP and FileZilla all work with the Windows OpenSSH server. Use Windows-style paths, such as scp file.txt username@pc:C:/Users/username/Desktop/.

How do I stop the SSH server?

Run Stop-Service sshd to stop it now, and Set-Service -Name sshd -StartupType Manual so it no longer starts with Windows. You can also uninstall OpenSSH Server from Optional features.

Is Remote Desktop better than SSH?

They do different jobs. Remote Desktop gives you the full Windows desktop. SSH gives you a lightweight command line that works from any device, is easy to script, and also handles file transfers and port forwarding.

Connecting to a Linux server too?

Our step-by-step guide covers SSH into any Linux server or VPS, including key login and locking down passwords.

How to SSH into a server