2

I would like to launch a GUI application on a Windows 10 Desktop machine via the built-in OpenSSH server. The issue is that it doesn't seem to render the GUI in the correct user session?

The application shows up in the task manager but does not render. I found some (ugly) workarounds that supposedly work on Windows 7 and 8 but not really something that works on Windows 10. Preferably this shouldn't involve changing how I launch the application but changing how the SSH server is launching programs.

I'm logged in via ssh as the user who is also logged into a Desktop session on the actual machine. On Linux you would have to specify which X11 sessions the app should launch in via an environment variable (e.g. DISPLAY=:0). Do I have to do something similar on windows to tell the shell in which context to launch the application?

timonsku
  • 676

2 Answers2

0

It does not seem easy to circumvent
Let's invent yet another wheel

Server side

  • Listen on a UDP port
  • Call ShellExecute(NULL,"open",...) on received packets
  • Able to open URLs in the default browser or launch GUI applications e.g. cmd/Taskmgr/mmc, which just pops up on the screen, all Linux_Xorg_SSH_DISPLAY=:0'ish
  • "It works on my machine." Works on Microsoft Windows [Version 10.0.19042.746]
  • No authentication implemented
  • Does not check what is in the UDP packet or if it is valid for ShellExecute()

Client side

  • Send a UDP packet for the server to execute
  • Save IP address of the server, provided in argv, so that you may omit it the next time
0

If the Windows OpenSSH service is not running you can start it from the intended user. A startup script is fine for that.

Create the user SSH keys in Windows (you usually do this anyways):

 ssh-keygen

Accept the default location. I tested it with no pass-phrase.

Start OpenSSH, using the user's private key as host key:

start /min %SYSTEMROOT%\System32\OpenSSH\sshd -h %HOMEDRIVE%%HOMEPATH%\.ssh\id_rsa

You could create a one-line sshd.bat with the above, and link to it from shell:startup.

axus
  • 239