3

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
  • 668
  • 8
  • 13
  • 1
    If you are logged onto a computer remotely you may not affect the physical user. Your program will be invisible. Otherwise the physical user would not have control of their machine. – Mark Jul 29 '20 at 02:19
  • Any way to circumvent that? Given that I have full ownership of the machine and can set it up however I want? On Linux this is absolutely no problem :/ – timonsku Jul 29 '20 at 20:08
  • 2
    It a security thing. You may not mount denial of service to a physical user. So Windows is designed to PREVENT it. Linux isn't as designed. Having said that https://docs.microsoft.com/en-us/sysinternals/downloads/psexec emulates the physical user. – Mark Jul 29 '20 at 20:37
  • 1
    Also PsExec is from a company MS bought and goes through contortions to do what it does. It copies files using hidden administrators shares, installs a service, that starts a program as the physical user.. The Windows way is to use Remote Help. You can take over the physical user's desktop. – Mark Jul 29 '20 at 20:45
  • Thanks for the pointers! – timonsku Jul 31 '20 at 16:14

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
Darren Ng
  • 369
  • 1
  • 3
  • 14
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
  • 1
  • 10