How to install the OpenSSH server on Windows with PowerShell
- November 19, 2021
- 0
Using SSH to remote into a Linux server is incredibly easy. Even installing the SSH server itself is a piece of cake. But when you have a need to SSH into a Windows machine, things get a bit more complicated. It’s not terribly challenging, but it’s not nearly as simple as it is with Linux.
I’m going to walk you through the process of installing the OpenSSH Server on Windows 10, configuring it to start at boot, and then show you how to log in from a Linux machine. You may not ever have a need to do this, but when you do, you’ll be glad you know.
Contents
What you’ll need
The only things you’ll need are a running instance of Windows 10, a user with admin privileges and a second machine to log in from.
With those in hand, let’s get to work.
How to install OpenSSH on Windows 10
The first thing to do is open PowerShell with admin privileges. Click the Start button and type PowerShell. When you see the entry, click Run as Administrator and then click Yes. Before we install, we have to find out which versions of the software are available, which can be done with the command:
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
You should see the following printed out in your PowerShell terminal:
Name : OpenSSH.Client~~~~0.0.1.0 State : NotPresent Name : OpenSSH.Server~~~~0.0.1.0 State : NotPresent
What the above means is neither the OpenSSH (version 0.0.1.0) client or server is installed. Let’s fix that. First, install the OpenSSH client with:
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
Next, install the OpenSSH server with:
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Now, if you issue the command:
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
Both client and server should be listed as Installed.
Next, we need to start the OpenSSH server with the command:
Start-Service sshd
Now, we’ll set the OpenSSH server to start at boot. For that, issue:
Set-Service -Name sshd -StartupType 'Automatic'
How to SSH into your Windows machine
This is where it gets a bit messy. First, you need to find out what your actual user account name is. To do that, click the Start menu and type cmd. When the terminal window opens, your username will be listed in the form of:
C:\Users\USERNAME
Where USERNAME is your actual username.
Next, you’ll need the password you used to setup your account on Windows 10. This might be your Hotmail password, your Skype password, or your OneDrive password.
With both of those pieces of information in hand, go to your Linux (or another Windows machine with OpenSSH installed) and log in with:
ssh USERNAME@IP
Where USERNAME is your Windows 10 username and IP is the IP address of your Windows machine. If you don’t know the IP address of your Windows machine, go back to the cmd terminal window on Windows and issue the command:
ipconfig/all
The IP address should be listed in the output.
You should be prompted for your Windows user password. If you try that password and it fails, you might have to make sure your Windows machine allows for password login. Many times, the Windows 10 desktops are configured to login via Windows Hello Face, Fingerprint, PIN or Security Key. Password is often left out of that. In order to enable password login, do the following:
- Open Settings.
- Go to Accounts.
- Click Sign-in Options.
- Disable the Require Windows Hello Sign-in for Microsoft accounts.
- Restart your computer.
When you go to login, you can still use your default method of authenticating, but you’ll be able to login with your account password via SSH. If you don’t disable the Windows Hello requirement, you might have trouble logging in via SSH.
Attempt to SSH into the Windows machine again. Hopefully, this time the process should complete and you’ll find yourself at the Windows terminal prompt, ready to do whatever it is you need to do on that machine.
[“source=techrepublic”]