Starting Windows GUI program in Windows through Cygwin sshd from ssh client

10

5

I would like to ssh into my Windows box running Cygwin sshd and run the Windows GUI application in that Windows box. I don't want X forwarding.

e.g. From ubuntu-server terminal, I ssh into Windows running sshd and then I launch a notepad.exe. The notepad.exe will display in Windows, not in ubuntu-server without X windows.

Win Myo Htet

Posted 2013-01-10T02:07:44.323

Reputation: 377

Answers

12

The proper method seems to have some issue:

http://cygwin.1069669.n5.nabble.com/Windows-GUI-programs-e-g-notepad-start-but-are-invisible-after-ssh-login-td56256.html

http://cygwin.com/ml/cygwin/2007-10/msg00334.html

Reinstall 'sshd' specifying the '-i' flag to 'cygrunsrv' or edit the current service under "Administrative Tools"->"Services" and check "Allow service to interact with desktop" in the "Log On" tab of the service's "Properties".

So I try some hack. I create a cygwin_screen.cmd and put it in the Windows Startup folder.

@echo off 
C:
chdir C:\cygwin\bin
bash --login -i "/home/username/bin/start_screen.sh"

start_screen.sh is simple and it will make sure that we have the screen to attach to.

#!/bin/bash
screen -dmS "my_screen"

Now I can remote login to Windows from ssh client and attach to that screen when I want to run the Windows GUI application.

$screen -d -r my_screen

$notepad.exe
$cygstart my_doc.doc

Win Myo Htet

Posted 2013-01-10T02:07:44.323

Reputation: 377

This solution works for me, but when I detach again, the client screen process hangs. I must ctrl-z out, and kill the process. Creating the daemon in one context (on the windows box), and attaching from another (ssh login) seems to create this problem. Creating and then attaching from my ssh connection doesn't cause the conflict. – Tim Rupe – 2015-02-27T22:49:16.433

1

Use PSTools and run the command like below from ssl client. ./PsExec.exe -i -d -s \\\\127.0.0.1 notepad

fx-kirin

Posted 2013-01-10T02:07:44.323

Reputation: 180

0

My solution is similar to Win Myo Htet's, except it uses tmux, which has more flexibility.

  1. Start tmux on a local Cygwin terminal.

    cygwin-host$ tmux

  2. Use ssh to run the command remotely, hosted in the tmux session.

    other-host$ ssh cygwin-host tmux new-window notepad

enigmaticPhysicist

Posted 2013-01-10T02:07:44.323

Reputation: 555