Setup SSH on Windows

How do you generally connect to your windows machine remotely?

I bet you use some 3rd party software or use Remote Desktop connection (uses RDP) to connect.

Now RDP is a SOAP based connection protocol and it is not that great either is it? I mean you can not easily use RDP from any other platform such as macOS or linux can you? Situation is even worse if you need to do it programmatically.

But hey! Did you know you could very easily use SSH? Well I did not!

It turns out our old faithful PCs can connect quite easily over SSH. We just have to enable a few settings and what better way to do this than firing up the Powershell?

First, let's clarify the terminology. The system that we will connect to is referred to as server (This has got to be a windows machine). The system that we will use to connect is referred to as the client (This can be running any desktop OS).

  1. Open Powershell on the server as Administrator and check if openssh services are available.
Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
  1. It can be that neither of the services are available. But mostly on newer windows installations, open-ssh clients are available. So, I will show how to install the server. Client can be installed similarly.
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
  1. Now start the open ssh server
Start-Service sshd
  1. Check if the services are running. Open SSH server needs to be running in order to make the device act as a server.
Get-Service sshd
  1. (Optional) Set the services to startup automatically on windows boot.
Set-Service -Name sshd -StartupType 'Automatic'

That's it! You can now ssh directly from your client terminal into this windows machine (server).