Linux SSH – How to Run Commands in Open X Session

linuxssh

I'm very sorry, I'm not currently aware of the correct terminology of what I'm trying to do, otherwise Google probably would have fixed this for me:

Essentially, I am SSH'd into a SUSE Linux box and need to run a "silent" mode command of a GUI app, that apparently needs an active X session to run/attach to.

If I am viewing the desktop on said box, open a terminal, the command runs fine, it just hangs when run from a remote shell.

I understand there should be a way to attach this command to the already existing X session (I don't need any output, it generates a file), but I don't know how to do that.

Am I right? Wrong? What should I be doing?

Best Answer

From a workstation that is already running X11 you can ssh in with the -X option to enable X11 forwarding. Or set the ForwardX11 option to yes in your ssh configuration file. If you are connecting from windows you probably want Xming and to enable X11 forwarding in Putty. (see this)

With X11 forwarding enabled it will allow the remote X11 applications to connect to and use the X11 server on your workstation.

The server will need to allow X11 forwarding. See the sshd_config and set X11Forwarding to yes.

If everything worked correctly then once you have connected running the running the command on the remote echo $DISPLAY should display something like this.

# echo $DISPLAY
localhost:10.0

You can also test by running simple like xclock or xeyes. The application should be displayed on your workstation.