Howto start an application remotely, so that GUI is shown locally
Solution 1
For your second question: add the -X (or -Y for a trusted connection) parameter when connecting with ssh and make sure you have X11 on your mac. Example:
ssh -X [email protected]
That would route your X11 windows to show on your local X server on your mac.
See: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/ssh.1.html
For the first question:
DISPLAY and AUTHORITY
An X program needs two pieces of information in order to connect to an X display.
It needs the address of the display, which is typically :0 when you're logged in locally or :10, :11, etc. when you're logged in remotely (but the number can change depending on how many X connections are active). The address of the display is normally indicated in the DISPLAY environment variable.
It needs the password for the display. X display passwords are called magic cookies. Magic cookies are not specified directly: they are always stored in X authority files, which are a collection of records of the form “display :42 has cookie 123456”. The X authority file is normally indicated in the XAUTHORITY environment variable. If $XAUTHORITY is not set, programs use ~/.Xauthority.
Extracted from: https://unix.stackexchange.com/a/10126
Refer to that post for a great explanation.
Solution 2
Remotely, you would need to set the display to use by exporting the DISPLAY environmental variable.
eg. export DISPLAY=:0
For your second question, the easiest way would be to set up VNC server on ubuntu and use a VNC client to connect from your Mac.
How-to: http://www.howtoforge.com/how-to-install-vnc-server-on-ubuntu-14.04
Related videos on Youtube
Peter Andersson
Updated on September 18, 2022Comments
-
Peter Andersson over 1 year
This is a beginners question, I know... but I have searched and I'm getting frustrated. I know my way around Lunux pretty well, but I have never had to deal with XServer.
Question 1:
I SSH from OSX into a UBUNTU 14.04 desktop machine as user alpha.
User alpha is also logged in locally on that desktop.
I want to run (via my terminal) an application that should show on the UBUNTU machine (so that its visible on the locally display of the locally logged in user).
Today I get this error when I do this from the OSX terminal:
15:21:20:157 AWT-EventQueue-0: Error java.awt.HeadlessException: No X11 DISPLAY variable was set, but this program performed an operation which requires it. at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:207) at java.awt.Window.<init>(Window.java:535) at java.awt.Frame.<init>(Frame.java:420) <etc>
NOTE: When I do it from the local terminal (on UBUNTU) it works as it should, so theres nothing wrong with the program.
Question 2:
In case the UBUNTU machine was headless, how would I divert the windows to another machine, for example my Mac?
Thanks Peter