Log in to Windows 10 via SSH

In this article, we will show you how to set up OpenSSH in Windows 10 and connect to them via SSH using Putty or any other SSH client.

 

The latest versions of Windows 10 include a built-in SSH server and an OpenSSH-based client. This means you can now connect to Windows 10 remotely using any SSH client, as in a Linux distribution. Let's see how.

Step 1: Make sure the version of Windows 10 is 1809 or newer. The easiest way to do this is to open a window prompt and run the command:
winver

Note: If you have an older version of Windows 10 installed, you can update it through Windows Update or using an ISO image with a newer version of Windows 10. If you do not want to update your version of Windows 10, you can install Win32 manually. -OpenSSH port for Windows from GitHub (https://github.com/PowerShell/Win32-OpenSSH) and avoid Step 2.

Step 2: Install the OpenSSH server in Windows 10 via the configuration panel:
Go to Settings > Apps > Optional .

Click + Add Feature, scroll down the list and find it OpenSSH server Secure shell server (SSH) based on OpenSSH, for secure keys and from remote machines).

Click on it and press the "Install" button

You can also install the sshd server using PowerShell:

Add-WindowsCapability -Online -Name OpenSSH.Server *

Ή using DISM:

dism / Online / Add-Capability /CapabilityName:OpenSSH.Server~~~~0.0.1.0

If you want to make sure the OpenSSH server is installed, open one PowerShell window and execute the following command:

Get-WindowsCapability -Online | ? Name -like 'OpenSSH.Server *'

Step 3: Check the status of ssh-agent and sshd services using the PowerShell Get-Service command:

Get-Service -Name * ssh *

Step 4: As you can see, both services are in downtime and are not added to the auto-start list. To start the services and set the auto-start for them, run the following commands, one by one:

Start-Service sshd Set-Service -Name sshd -StartupType 'Automatic' Start-Service 'ssh-agent' Set-Service -Name 'ssh-agent' -StartupType 'Automatic'

you should also allow incoming connections to TCP port 22 on Windows Defender Firewall (if enabled):

netsh advfirewall  add rule name=”SSHD service” dir=in action=allow protocol=TCP localport=22

Step 5: You can now connect to Windows 10 using any SSH client. To connect from Linux, use the command:

ssh -p 22 admin@192.168.1.90

where admin enter the local Windows user to whom you want to connect and where 192.168.1.90 enter the LOCAL IP address of your Windows 10 computer.

Note: The above example refers to a connection within a local private network (intranet). If you want to connect from another network you need to make settings on your router so that the demand on port 22 leads to the specific Windows computer, as well as to know at all times the external IP provided by your provider.

A successful connection will open a new Windows command prompt window.

Trick: To run the PoweShell console instead of the command prompt (cmd.exe) when connecting via SSH in Windows 10, you must run the following command in Windows 10 (under admin account):

New-ItemProperty -Path “HKLM: \ SOFTWARE \ OpenSSH” -Name DefaultShell -Value “C: \ Windows \ System32 \ WindowsPowerShell \ v1.0 \ powershell.exe” -PropertyType String –Force

So you change the default OpenSSH shell in the registry. Now, when you connect to Windows via SSH, you will immediately see the PowerShell prompt instead of cmd.exe.

If you want to use key-based ssh authentication instead of password authentication, you must create 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.

After that, you can sign in from the Linux client computer in Windows 10 without a password. Use the command:

ssh -l admin@192.168.1.90

You can configure various OpenSSH server settings in Windows using the %% programdata% \ ssh \ sshd_config configuration file.

For example, you can turn off password authentication and leave only key authorization with:

PubkeyAuthentication yes PasswordAuthentication no

iGuRu.gr The Best Technology Site in Greecefgns

every publication, directly to your inbox

Join the 2.087 registrants.

Written by Dimitris

Dimitris hates on Mondays .....

Leave a reply

Your email address is not published. Required fields are mentioned with *

Your message will not be published if:
1. Contains insulting, defamatory, racist, offensive or inappropriate comments.
2. Causes harm to minors.
3. It interferes with the privacy and individual and social rights of other users.
4. Advertises products or services or websites.
5. Contains personal information (address, phone, etc.).