1

I know there are many variations on this question, but I could not find a solution to this exact scenario.

Setting: local computer, remote computer (on the same local network). On the local computer (Ubuntu 20.04), I have the following lines in ~/.ssh/config:

Host remote
    User username
    HostName remote.local
    Port 223
    ForwardX11 yes
    ForwardX11Trusted yes

On the remote machine (Ubuntu 22.04) I have the following lines in /etc/ssh/sshd_config:

Port 223
X11Forwarding yes
X11DisplayOffset 10

(Of course, the port does not matter). I connect via ssh remote, and that works with no issues. The DISPLAY variable is set (good) to localhost:11.0 (perhaps sometimes to localhost:10.0). When I run xclock or xlogo, I see it fine. Works perfectly.

But here's the problem: whenever I run almost any other GUI app, it doesn't work. Sometimes, errors are printed, and sometimes, they fail quietly. Examples:

  1. Running eog picture.png fails quietly. I don't see any message, nor the picture.
  2. Running evince, I don't see the PDF, and I see repeating error messages: gdk_monitor_get_scale_factor: assertion 'GDK_IS_MONITOR (monitor)' failed. gnome-calculator fails with a similar error.
  3. Running firefox fails (I don't see the browser, even when the process did not exist earlier), and I see repeating error messages: X11 connection rejected because of wrong authentication.
  4. Running firefox a second time after disconnecting and reconnecting, the error message has changed: Error: cannot open display: localhost:11.0.

At this point, I'm a bit lost.

I also connected in a verbose mode, to look for interesting problems. The only potentially relevant lines I have found there are

debug1: Remote: /home/username/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Remote: /home/username/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug2: channel_input_open_confirmation: channel 0: callback start
debug2: x11_get_proto: /usr/bin/xauth  list :0 2>/dev/null
debug1: Requesting X11 forwarding with authentication spoofing.
debug2: channel 0: request x11-req confirm 1

Looks OK, doesn't it?

My use case is actually very simple: I need to plot graphs from within sage (or Python) remotely and see them locally. I was able to achieve this in the past with different computers, but that was a while ago. My workaround is to save the plots and open them locally (via sshfs), which is a bit silly.

2
  • 2
    Are you running X11 or Wayland (with XWayland) on you local computer? I would suggest you try to change that and see what happens.
    – nobody
    Jan 12 at 13:24
  • I am running X11 locally.
    – Bach
    Jan 12 at 14:27

1 Answer 1

4

The problem is that you are running Wayland remotely and the applications default to that.

Once you start the session you can do:

$ export GDK_BACKEND=x11

And normal (deb installed) applications will be forwarded. So you will be able to use eog and evince for example.

Firefox is most likely a snap in your configuration. There has been an issue with snaps for a very long time. This is one such bug at the snap bug tracker: "X11 connection rejected because of wrong authentication." when using snaps over ssh. The last comment states that the bug is been triaged and there are workarounds, but the workarounds no longer work (either exporting XAUTHORITY or linking .Xauthority to a place where the snap can see it).

Two alternatives for firefox:

  • you could start the gdm sesion using X11 (logout, and at login, when you have to type the password there will be a cogwheel offering the type of session).
  • download the firefox binary from firefox.com for your platform and run it instead of the snap. Since it is no longer a snap, it should work as evince and eog. It will also prompt you when there is a new version, to download it and update itself.
2
  • Thanks for your answer! You are correct; it appears that I am running Wayland on the remote computer. I tried to SSH, run the export command you suggested, and then run eog, but it did not help (I mean, nothing happened). Running evince worked. Plotting from sage did not (main use case). I will try restarting the gdm session using X11 and report back.
    – Bach
    Jan 15 at 7:58
  • That worked! This was indeed the issue. Thank you so much for your help!
    – Bach
    Jan 17 at 8:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .