Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

like image 216
ALEX Avatar asked Jan 23 '20 14:01

ALEX


People also ask

Can you run GUI over SSH?

SSH, the Secure Shell, supports remote login and command-line or GUI access across the network through encrypted tunnels protected by public-key cryptography.

Does PuTTY support GUI?

As well as the traditional terminal window command line interface, PuTTY can be configured to open graphical applications on the remote computer.

How do I know if OpenSSH is installed on Windows?

To check if SSH is enabled on your system, open a command prompt and end the command ssh . If it provides you with help for using SSH, it is already enabled!

How do I start OpenSSH server?

After OpenSSH was installed i started it. You can get to it easily by typing "services" into the Windows Search Bar, scroll down and find "OpenSSH SSH Server", right click and click "Start". You can also set the service to start automatically by right clicking, select Properties and set Startup type "Automatic".

How to run GUI application via SSH?

How to run GUI application via SSH SSH is normally used for remote access and administration where tasks are done from the CLI (Command Line Interface), using command line tools. SSH can forward the display or GUI from the SSH server to the client, enabling running X11/X or graphical apps from within an SSH session.

What is Windows 10 OpenSSH?

Applies to Windows Server 2019, Windows 10 OpenSSH is a connectivity tool for remote login that uses the SSH protocol. It encrypts all traffic between client and server to eliminate eavesdropping, connection hijacking, and other attacks.

What devices can I connect to with OpenSSH client?

OpenSSH can be used to connect Window 10 (build 1809 and later) or Windows Server 2019 devices with OpenSSH Client installed to those devices with OpenSSH Server installed.


Video Answer


2 Answers

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

like image 111
domih Avatar answered Oct 13 '22 20:10

domih


The "solution", using a third party ssh server is this:

  1. Uninstall the Optional Feature "OpenSSH Server" of Windows10
  2. Download and install the third party ssh server. I used freeSSHd
  3. DO NOT install this software AS AS SERVICE.
  4. Set users allowed in the Settings of the software.
  5. 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

like image 43
ALEX Avatar answered Oct 13 '22 18:10

ALEX