How to: Use OpenSSH in Windows systems

Learn how to connect to a Unix shell over SSH with PowerShell or CMD.


About OpenSSH

OpenSSH is a tool to remotely controlling a server. It is developed by the OpenBSD project. The first release of OpenSSH was in 1999.

OpenSSH has been added to Windows since 2018, and is included in Windows 10 and Windows Server 2019. With OpenSSH for Windows there are more ways to connect to SSH, then only using the PuTTY client.

Using OpenSSH in Windows systems

To install OpenSSH, run PowerShell as admin on your Windows device and run the following to check if the OpenSSH client already is installed:

Get-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0

If not already installed run:

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

Now that OpenSSH has been installed you can use it within PowerShell or CMD to connect to your Unix shell in Azure or locally. To connect to an external Unix shell run:

ssh usernameofvm@IP.address

SSH connects over port 22. Keep in mind that you don’t open port 22 for any connection. The best way is to connect using a SSH private key file. In Azure you can create the key file while creating your VM. To connect using a key file run:

ssh -i <private key path> usernameofvm@IP.address

On my Windows machine I want to have an Unix shell for tools like OpenSSL (even there is also a Windows version), Dig, Nmap and Sendmail with opendkimtools for testing domain spoofing and policies like Microsoft 365’s anti-spam and anti-phising.

I am using a local Debian (Buster) minimal (shell only) installation, running in VirtualBox with only 1024MB of RAM. Using a VM feels better to me then using WSL. I run this VM headless and setup portforwarding within the VirtualBox VM.

To forward a port in VirtualBox attach the network adapter of the VM to NAT (not bridged) and forward the hostport on port 22022 (or any other none existing port) to guest port 22. With this setup you can access this VM by running:

ssh usernameofvm@localhost -p 22022

Now you know about diffrents ways to access an Unix shell with OpenSSH. You can connect from PowerShell or directly in CMD. You can also use tools like VSCode or the fancy Windows Terminal app (with the retro appearance!).