On the Window machine that you want to SSH onto, run PowerShell as administrator and issue the following command to determine if OpenSSH server is installed (by default, it's not installed).
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
Something like this will probably be returned.
PS C:\WINDOWS\system32> Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
Name : OpenSSH.Client~~~~0.0.1.0
State : Installed
Name : OpenSSH.Server~~~~0.0.1.0
State : NotPresent
Assuming OpenSSH Server is not installed, issue this command to install the OpenSSH Server.
Add-WindowsCapability -Online -Name OpenSSh.Server~~~~0.0.1.0
Then re-issue the prior command and it should show that OpenSSH Server is now installed.
PS C:\WINDOWS\system32> Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
Name : OpenSSH.Client~~~~0.0.1.0
State : Installed
Name : OpenSSH.Server~~~~0.0.1.0
State : Installed
The OpenSSH Server sshd service should be stopped.
PS C:\WINDOWS\system32> Get-Service sshd
Status Name DisplayName
------ ---- -----------
Stopped sshd OpenSSH SSH Server
Start the OpenSSH Server sshd service.
PS C:\WINDOWS\system32> Start-Service sshd
And now the OpenSSH Server sshd service should be running.
PS C:\WINDOWS\system32> Get-Service sshd
Status Name DisplayName
------ ---- -----------
Running sshd OpenSSH SSH Server
Determine if SSH port 22 is allowed in Windows Firewall and optionally add a rule to allow SSH port 22.
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."
#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' is already allowed"
}
Use the whoami command to get your username.
PS C:\WINDOWS\system32>whoami
johndoe
From another machine in the same network as your Windows machine, you should now be able to SSH onto the Windows machine.
~]# ssh johndoe@10.14.5.13
johndoe@10.14.5.13's password:
Microsoft Windows [Version 10.0.22621.1555]
(c) Microsoft Corporation. All rights reserved.
johndoe@APPDEV C:\Users\johndoe>
Did you find this article helpful?
If so, consider buying me a coffee over at