1

I am trying to run a GUI application (if only it weren't GUI...) over SSH, but I want it to port the application to the native X session and not the SSH session. That way, when I close the SSH session, the program will remain running. I am logging into the box with the same user that is already logged into the box and I have root privileges. The x session on the box is UserA and I am logging in via SSH as userA. The OS is Ubuntu 13.04.

Is there a way to do this easily? Any past attempts always attempted to show the X window client-side and when I closed SSH, the program stopped running. I also thought about going in and editing the startup script of the session and simply rebooting the machine to get it to run what I want, but it has a few server programs that I don't know how to access (they are command-line based) to properly shut them down remotely. If I kill the machine otherwise, it will likely corrupt the server software.

2

You can forgo the SSH session if you can directly connect from the server running the X client application to your local computer running an X server.

Connect over SSH, and then:

export DISPLAY=your.computer.ip:0.0

This will tell the X client that it should connect to the first X server and find the first X display (0.0) on your.computer.ip. Just launch the X client application as normal, and it should connect to your X server directly, and you can then close the SSH session.

You will need to make sure that a direct connection can be made from wherever the client is running to your local system, including any port forwarding and routing rules. You might have to also configure your local X server to accept connections from the network (I can't remember if it's localhost only by default). You will also need to fully disable all security on the X server (Don't do this unless you're in a private LAN where you can trust all computers):

xhost +

or learn how to properly configure and set up X authentication between clients.

In all honesty, this is exactly what happens when you do it normally over SSH - Except that the SSH tunnel is being used to forward the connection, so you don't have to deal with the port forwarding, and you don't have to deal with changing your X server config to listen on the network for incoming connections (a potential security risk), and SSH will automatically configure all of the X security for your user so that the application won't have issues connecting. Even running through SSH, the application is running in the native X session, SSH is just being used as a proxy.

You didn't list the reasons for eschewing SSH, but unless it's a hard requirement handed down by a boss that you can't change, I would strongly reconsider using it for X session forwarding. You will not gain anything in particular from a direct connection, but SSH can simplify a lot of the pain points because it was designed to do just that.

  • Allow me to elaborate that the GUI application is on the server. I just need to initialize it on the server and stop SSH from routing the GUI window to my client. From what I read, it looks as if you are trying to setup a method by which I could run an application on my client, and instead have it forwarded to the server. The app is on the server and needs to be run on the server. – Signify Apr 19 '13 at 15:03
  • Ah! Yes, that is what I was suggesting. To do what you want, try launching it after export DISPLAY=localhost:0.0 or export DISPLAY=:0.0, and then make sure to run it from inside screen or tmux or the process will die when the SSH session dies. You can also disown the process before exiting to have it continue running when you close the SSH window. – Darth Android Apr 19 '13 at 15:22
  • That works like a charm. I can't get it to keep running after I close the session, but at least it lets me get the screen-capture program running. – Signify Apr 19 '13 at 15:22
  • I just updated my comment with a suggestion on how to keep it running in the background after some research. – Darth Android Apr 19 '13 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.