Ssh – Problems starting a program on Windows when running SSH as a service

runasssh

I'm trying to set up a Windows machine as an SSH server so that I can SSH to it from another Windows machine.

I installed OpenSSH on the server and can successfully connect to it from another Windows client using Putty. I'm trying to write a script that will open a specific application and then run an Autohotkey script to perform some action within that application. I have a batch file on the SSH server. If I run that batch file locally it does exactly what I want it to do: it opens the application, runs the Autohotkey script, and exits gracefully. However, if I open that same batch file through an SSH session, the application process starts (I see the process in Task Manager), but the GUI doesn't actually open. From what I've been able to find, it's likely due to the fact that SSH is running as a service and will not open the application as the currently logged in user. To try to circumvent this, I attempted the "runas" command. Again, I have the same outcome (the .exe shows up in Task Manager, but the GUI doesn't open). Additionally, both of these methods open the AHK script but the script doesn't perform any actions.

I've also tried another SSH server, freeSSHd, that does NOT run as a service. Using this, I can get the script to do exactly what I want via SSH. However, this solution doesn't work for me because ideally there won't be any peripherals connected to the SSH server. It will just be connected to the network via Ethernet. If it's not running as a service, that means I'll need to manually open the application and click on the "Start SSH server" button each time it restarts.

How can I open a GUI application over SSH?

Thanks

Best Answer

Services are restricted from showing any UI elements; they get put on a thingy (Desktop or Windows Station or something, doesn't matter at the moment). So anything GUI is not going to work.

You would need a way to create a new thingy, and then put the application that thingy, all from the SSH login session. While it might be possible to build something to do that, it would be a waste of time, since it's already been done. It's called Remote Desktop Connection (RDC), AKA Remote Desktop Protocol (RDP). Use RDP instead of SSH. Use an RDP client instead of an SSH client.

If, for whatever reason, you have to use SSH, use SSH to establish the connection to the computer, and then use SSH port forwarding to tunnel RDP.

If, for some reason, you don't think you can use RDP, please explain why.

Related Topic