I've read the edited version of the question, and if I understand you correctly, you want to run a program from SSH without showing you the GUI... you just want to run the program and it depends on X Windows, so you need it to connect somehow to X Windows on the server itself.
There are two things you need to do. You need to allow connections from outside of X Windows, and then you need to tell the shell (in SSH) which X server to bind to.
First, allow incoming connections to the X server. Open up a terminal window in X Windows on the server machine. (You must have access to that, otherwise you cannot do this.)
Issue the following command:
xhost +
It should tell you "connections allowed from all hosts" or something to that effect.
Then, while still remaining in X Windows, issue:
echo $DISPLAY
This will tell you the display ID. Write it down or remember it. Typically it will be ":0" or ":0.0" but don't worry if it's different.
That's all you need to do from within X Windows itself.
Now SSH into the server from wherever you want. Issue the command:
export DISPLAY=[what-the-echo-command-gave-you]
And that should be it! Now you should be able to run any X windows from that SSH shell, and it will pop up on the local X Windows server.
Hope it helps!
4
xhost +
is an exceedingly bad idea. If your user started the Xserver then you should have the appropriate Xauthority file already, no need to mess around with the server host acls. – Geoff Reedy – 2010-06-17T20:55:36.390@GeoffReedy I do not understand what you mean. Following Helgi's instructions, I managed to fire up an application from SSH. How could I do it without
xhost +
? What are the risks I'm taking (I had to login anyway)? – Camilo Martin – 2012-02-11T00:27:36.2971
@CamiloMartin @Helgi
– Geoff Reedy – 2012-02-13T15:31:03.857xhost +
turns off all access control for the x server. Anyone who can connect to the X server can snoop events, inject events, dump window contents, kill programs running on the X server, etc. These capabilities could be used as a denial of service, arbitrary program execution or other bad things. See http://www2.slac.stanford.edu/computing/security/xwindow/ for some more info on this. What you should do under most setups is runecho $XAUTHORITY
instead. If it is not empty, then when you want to run a GUI program doexport XAUTHORITY=<saved content of $XAUTHORITY>
.@GeoffReedy, thanks for the tip. I haven't used this trick myself for years, but next time I'll be sure to search for Xauthority instead. – Teekin – 2012-02-13T15:31:19.643
@GeoffReedy Thank you very quite a bit much some lot. Made it into a script! Put this
– Camilo Martin – 2012-02-17T04:21:59.043gimme-xauth.sh
in your /usr/bin for pleasure and Xstasy. http://pastebin.com/GXx2hwC5Oh and note that it only works for gdm, I'm a n00b so I dunno how to make it more agnostic. I also don't currently have a non-gdm3 box anymore... – Camilo Martin – 2012-02-17T04:28:51.423
Now, the script does not work correctly: export has to be typed in ssh anyway (which still helps, as I can type it since it's shown). Anyone knows why? – Camilo Martin – 2012-02-17T04:39:18.460