Share your love
How To SSH into a Windows Machine

In this guide, you will learn How To SSH into a Windows Machine. OpenSSH is a connectivity tool for remote sign-in that uses the SSH protocol. It encrypts all traffic between client and server to eliminate eavesdropping, connection hijacking, and other attacks.
An OpenSSH-compatible client can be used to connect to Windows Server and Windows Client devices. Now, proceed to the guide steps below on the Orcacore website to learn how you can enable SSH and access a Windows machine using SSH.
Table of Contents
Steps To SSH into a Windows Machine
In this article, we’ll show you how to configure OpenSSH on Windows and connect to it using Putty or any other SSH client. Let’s start by enabling SSH on Windows.
1. How To Enable SSH Server on Windows?
If you are using a Windows 10 machine, you need to be sure that your build of Windows 10 is 1809 or newer. To do this, you can run the command below:
winver
Note: If you have an older Windows 10 build installed, you can update it through Windows Update.
Then, run the command below from your PowerShell Admin to enable OpenSSH on your system:
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

Verify your OpenSSH status by running the following PowerShell command:
Get-WindowsCapability -Online | ? Name -like 'OpenSSH.Server*'

Then, start the SSH server by using the command below:
Start-Service sshd
Next, run the command below to autostart the SSH server:
Set-Service -Name sshd -StartupType Automatic
2. Configure SSH Agent on Windows
At this point, you need to check the status of ssh-agent from your PowerShell:
Get-Service -Name ssh-agent

In my case, the service is in a Stopped state and not added to the automatic startup list. To start the SSH agent service and configure autostart for it on your Windows machine, run the following commands:
# Set-Service -Name ssh-agent -StartupType Manual
# Start-Service ‘ssh-agent’
# Set-Service -Name ‘ssh-agent’ -StartupType 'Automatic'
3. Configure Windows Firewall For SSH
At this point, you need to allow incoming connections to TCP port 22 in the Windows Defender Firewall. To do this, you can add a firewall rule to allow SSH traffic using PowerShell on your Windows machine:
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22

Now you can start to connect to your Windows.
4. Connect From Linux To Windows Using SSH
At this point, you can connect to Windows using any SSH client. To connect from Linux, use the command below:
ssh -p 22 admin@IP-address-of-your-windows-machine
Here, the admin is a local Windows user under whom you want to connect. After that, a new Windows command prompt window will open in an SSH session.
5. Generate SSH Keys on your Windows Machine
If you want to use key-based SSH authentication instead of password authentication, you need to generate a key using ssh-keygen on your client.
Then, the contents of the id_rsa.pub file must be copied to the c:\users\admin\.ssh\authorized_keys
file in Windows 10.
You can configure various OpenSSH server settings in Windows using the %programdata%\ssh\sshd_config
configuration file.
For example, you can disable password authentication and leave only SSH key-based auth on your Windows machine with:
PubkeyAuthentication yes
PasswordAuthentication no
Here you can also specify a new TCP port (instead of the default TCP 22 port) on which the SSHD will accept connections. For example:
Port 2222
After making changes to the sshd_config file, you need to restart the sshd service:
Get-Service sshd | Restart-Service –force
After that, you can connect from your Linux client to Windows without a password. Use the command:
ssh -l admin@IP-address-of-your-windows-machine
Conclusion
At this point, you have learned to SSH into a Windows Machine and enable PubkeyAuthentication to connect to your system without a password.
Hope you enjoy it. Please subscribe to us on Facebook, Instagram, and YouTube.
You may also like these articles:
How To Change RDP Port on Windows
Set up Apache Tomcat on Windows 10/Server