'Starting GUI programs via OpenSSH on Windows?
I'm trying to execute a labview VI, launching that from a .bat file, called via ssh, from another Windows machine. So I do
ssh myuser@IP
cd Desktop
launchVis.bat
I connect with user and password. myuser have all the rights to launch the batch file. Meanwhile I check the execution via RDP connection on the same machine.
If I run the bat file from a cmd line on the remote machine, the VI starts normally If I run the bat file from the ssh connection, i can see the output of echoes in the bat file but LabVIEW will be launched in a different session from RDP-TCP#1. The result is that I can see a "LabVIEW" process started in a Session named Services, but I cannot see the VI executing and in general, I don't know IF is executing or not.
Googling about the problem, It seems that I cannot avoid to start processes in "Services" Session and, for this reason, I cannot launch any GUI Program via SSH. Suggested solutions are using PsExec or, maybe a third part of ssh Server (with a third part ssh Server I reached my goal over Windows 7)
Solution 1:[1]
Running SSHd as a service makes launching desktop applications difficult, because a service has no access to the user desktop (Windows Station, WinSta0) link
Option 1: Start SSHd as a user
- This fails with the latest OpenSSH implementation with
fork of unprivileged child failed, as running SSHd as a user is no more possible since OpenSSH 7.5 released in 2017 link - Use an old implementation or a fork of OpenSSH, e.g. dropbear, FreeSSH or similar
Option 2: Use a launcher that has access to the Windows Station
On Windows, there are 2 options left to launch desktop applications over SSH: link to Github OpenSSH issue
- schtasks
- psexec on localhost
Usage:
ssh user@host "psexec -i 1 mydesktoplauncher.bat"
See psexec documentation for optional arguments like -i 1
Solution 2:[2]
The "solution", using a third party ssh server is this:
- Uninstall the Optional Feature "OpenSSH Server" of Windows10
- Download and install the third party ssh server. I used freeSSHd
- DO NOT install this software AS AS SERVICE.
- Set users allowed in the Settings of the software.
- Put a link to the exe of this software in the shell::startup folder, so it will be run at startup.
In that way, the ssh server will be launched as user and CAN execute GUI programs.
Unfortunately, I didn't manage to achieve the same goal with the Windows official OpenSSH server, because it fail to be launched as User, but seems working only as a Service
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Bumsik Kim |
| Solution 2 | alastairtree |
