I have mac with xquartz as a remote client for X11 on my latest ubuntu linux. I am able to connect with ssh and start applications like xclock remotely. With most of the apps like gnome-calculator the app opens in ubuntu local display instead of remote display as intended. SSH configuration should be fine and to my best understanding this has something to do with display parameter in x11 forwarding. Any help will be appreciated.
I had the same problem with
ssh -X user@remote. Some applications are showing on local side (e.g. xclock), and some on the remote side (e.g. gedit). I believe this is a problem is with all GTK/Gnome applications. It only happened when a remote display was running (I was using NoMachine at the same time)
I found a workaround: unset XDG_RUNTIME_DIR environment variable.
ssh -X -C user@remote unset XDG_RUNTIME_DIR gnome-calculator
The same effect is by using
su - $USER. The
- is important here
ssh -X -C user@remote su - $USER gnome-calculator
Now application shows on local display always, even when a remote desktop is opened.
I've read the three posts here, and I think there is a little misunderstanding of the
The intention of the
-X option of the
ssh client is to forward a remote display to a local one thus you can run remote resources and view them locally... for more information read
When you are using
su these commands just break the normal work of the X-forwarding, thus the GUI applications are running on the remote display. Something more when you are using
sudo some-gui-app it breaks the ownership of the files in your
$HOME directory, which could cause some issues - the fix is:
sudo chown -R $USER:USER $HOME, and next time use
sudo -i ... or
sudo -H ....
In order to run a GUI application on the remote display from within ssh session, you need to
export the values
$XAUTHORIT (and in some cases some other variables) of the desktop session where you want to run the application - normally this is the active session, where the user is logged-in and the session is displayed on the physical screen.
Time ago, I've developed a bash script that is able to detect the active desktop session and export all its variables from within the current session (ssh|cron|tty|etc.). Initially I needed to solve similar task for
crontab, this is the reason of the original name of the script
cron-gui-launcher, but it has a wider field of usage. The script, all necessary explanations, and couple of example of usage are available within my GitHub's repository: https://github.com/pa4080/cron-gui-launcher.
Here is a video demonstration how the script works: Ubuntu: CRON GUI Launcher Demo - SSH.