The latest versions of Windows 10 include a built-in server SSH and one client based on OpenSSH. This means that you can now connect to Windows 10 from afar, 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 command prompt window and run the command:
Note: If you have an older version of Windows 10, 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 their version Windows 10, you can manually install Win32-OpenSSH port for Windows from GitHub (https://github.com/PowerShell/Win32-OpenSSH) and avoid Step 2.
Click on it and press the "Install" button
You can also install the sshd server using PowerShell:
Add-WindowsCapability -Online -Name OpenSSH.Server *
Or using DISM:
dism / Online / Add-Capability / CapabilityName:OpenSSH.Server ~~~~ 0.0.1.0
Get-WindowsCapability -Online | ? Name -like 'OpenSSH.Server * '
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 up auto-start for them, run the following commands, one by one:
Start-Service sshd Set-Service -Name sshd -StartupType 'Automatic' Start-Service 'ssh-actor 'Set-Service -Name'ssh-agent '-StartupType' Automatic '
you should also allow incoming connections to TCP port 22 on the Firewall Windows Defender (if enabled):
netsh advfirewall firewall add rule name = ”SSHD service” dir = in action = allow protocol = TCP localport = 22
ssh -p 22 [Email protected]
Note: The above example refers to a connection within a local private network (intranet). If you want to connect from another network you have to make settings on your router so that the demand on port 22 leads to that Windows computer, as well as to know at all times the external IP given to you by your provider.
After a successful connection a new command prompt window will open Windows.
New-ItemProperty -Path “HKLM: \ SOFTWARE \OpenSSH”-Name DefaultShell -Value“ C: \Windows\ System32 \ WindowsPowerShell \ v1.0 \powershell.exe ”-PropertyType String –Force
For example, you can turn off password authentication and leave only key authorization with:
PubkeyAuthentication yes PasswordAuthentication no