Help / Guides / Windows: enable Remote Desktop and SSH

Guides

Windows: enable Remote Desktop and SSH

Commands to turn on Remote Desktop and OpenSSH Server on a lab Windows machine.

Updated Oct 21, 2026

Run everything below on the Windows machine in PowerShell as Administrator (right-click Start, then Terminal (Admin)). Paste one line at a time.

Remote Desktop

Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name fDenyTSConnections -Value 0; Enable-NetFirewallRule -DisplayGroup 'Remote Desktop'

SSH (OpenSSH Server)

Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Set-Service -Name sshd -StartupType Automatic; Start-Service sshd
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22

Optional, lands you in PowerShell instead of cmd when you SSH in:

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

Network profile

Both services are blocked while the network is marked Public. Set it to Private:

Set-NetConnectionProfile -InterfaceAlias Ethernet -NetworkCategory Private

Verify

Get-Service sshd
Get-NetConnectionProfile
Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name fDenyTSConnections

fDenyTSConnections should be 0, sshd should be Running, and the profile should be Private.

Here is the complete script

Everything above in one block. Paste it whole into the Administrator PowerShell window.

Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name fDenyTSConnections -Value 0
Enable-NetFirewallRule -DisplayGroup 'Remote Desktop'
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Set-Service -Name sshd -StartupType Automatic
Start-Service sshd
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
New-ItemProperty -Path 'HKLM:\SOFTWARE\OpenSSH' -Name DefaultShell -Value 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' -PropertyType String -Force
Set-NetConnectionProfile -InterfaceAlias Ethernet -NetworkCategory Private
Get-Service sshd
Get-NetConnectionProfile
Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name fDenyTSConnections

Single-line version

Same script as one line, for terminals that reorder or split multi-line pastes:

Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name fDenyTSConnections -Value 0; Enable-NetFirewallRule -DisplayGroup 'Remote Desktop'; Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0; Set-Service -Name sshd -StartupType Automatic; Start-Service sshd; New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22; New-ItemProperty -Path 'HKLM:\SOFTWARE\OpenSSH' -Name DefaultShell -Value 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' -PropertyType String -Force; Set-NetConnectionProfile -InterfaceAlias Ethernet -NetworkCategory Private; Get-Service sshd; Get-NetConnectionProfile; Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name fDenyTSConnections

Source: content/guides/windows-remote-access.md · maintained in the lab docs repository.