Knowledge Base
Searching in : Article
ID: AR05V01231
Applies to: NoMachine Software
Added on: 2024-05-15
Last Update: 2025-03-12

Solving "The connection with the server was lost" when connecting to Windows with OpenSSH server v8.6

Problem is fixed in Windows 11 24H2, which includes OpenSSH 9.5p1. Users can update their Windows version or install the new OpenSSH by hand as suggested in this article.


NoMachine server v8 uses by default its built-in SSH server (nxsshd) for accepting connections by SSH protocol.

As an alternative, it's possible to use the OpenSSH Server included in Windows 10 and Windows Server 2019 (1809) and later versions (see: https://www.nomachine.com/AR03S01117).

In this case, a known problem of OpenSSH version 8.6 (introduced in Windows 11 with the 23H2 update):
https://github.com/PowerShell/Win32-OpenSSH/issues/2011
affects also NoMachine connections by SSH.

In this case when trying to login to the NoMachine server, this error occurs:
"The connection with the server was lost"
and a crash of sshd.exe is reported in the EventViewer.

This problem has already been fixed in OpenSSH 9.1 for Windows, but until it is included in next Windows Update, the workaround is to update OpenSSH manually.

Changelog  from Win32-OpenSSH repository on GitHub:
https://github.com/PowerShell/Win32-OpenSSH/releases/

Instructions from UI

First step - uninstall OpenSSH 8.6:
1. In Windows Settings go to System -> Optional Features
2. Look for OpenSSH Server, click on it and select "Remove"

Second step - download OpenSSH v9.1 or later
From GitHub repository download new version of OpenSSH (e.g. for v9.2.2.0):
https://github.com/PowerShell/Win32-OpenSSH/releases/download/v9.2.2.0p1-Beta/OpenSSH-Win32-v9.2.2.0.msi

Then install it by double click on the .msi file and follow the instructions.

Third Step - Start SSHD service if it is not started already
1. Open Services application and look for OpenSSH Server.
2. Right click and go to Properties
3. Set "Startup type" to "Automatic" and start the service

Fourth step -  Add firewall exception for SSHD port if it is not already added
There are two methods, the second one is more advanced and allow to control additional settings or even to create rule for specific port with no need to restrict an app path.

First method
in Windows Setting go to "Network & Internet" -> "Windows Firewall" -> "Allow an app through firewall"
Click "Change settings" then "Allow another app..." and select file sshd.exe from OpenSSH installation directory.

Default path: C:\Windows\System32\OpenSSH\sshd.exe

Second method
in Windows Setting go to "Network & Internet" -> "Windows Firewall" -> "Advanced Settings"
Open "Inbound Rules" tab and create "New rule..."
Set:
"Rule type" - "Program", "This program path" - path to sshd.exe file, "Action" - "Allow the connection", "Profile" - left all (Domain/Private/Public) selected, "Name" - "OpenSSH Server"

 


Instructions from PowerShell

First step - Uninstall OpenSSH v8.6 by running:

Remove-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

Second step -  download and install new OpenSSH (9.1 or later).
E.g. for 9.2.2.0, on a single line in PowerShell, execute:

Invoke-WebRequest
https://github.com/PowerShell/Win32-OpenSSH/releases/download/v9.2.2.0p1-Beta/OpenSSH-Win32-v9.2.2.0.msi
-OutFile $HOME\Downloads\OpenSSH-Win32-v9.2.2.0.msi -UseBasicParsing

then:

msiexec /i $HOME\Downloads\OpenSSH-Win32-v9.2.2.0.msi
 

Third step -  Start SSHD service if it is not started already:

Start-Service sshd


then set up to start it automatically:

Set-Service -Name sshd -StartupType 'Automatic'
 

Fourth step -  Add firewall exception for SSHD port if it is not already added, on a single line execute:

New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22