SSH X11 port forwarding

2022-03-12 Off By Tim

When you are following all of the wonderful instructions on enabling X11 port forwarding, so that your non-GUI server can shoot a window back to your GUI machine that is running vino. You’ve done the ‘X11Forwarding yes’. You’ve turned on ‘X11DisplayOffset 10’. Restarted all of the services. Changed the client configuration file too. Set and exported your “DISPLAY=guimachine:0”. And still, all you see is “xterm: Xt error: Can’t open display guimachine:0”

Command: $ ssh -X machinenogui

Solution: on the machinenogui, in the file /etc/ssh/sshd_config, make sure you have this line:

X11UseLocalhost no

Because: it turns out “#X11UseLocalhost yes” (i.e. a commented out yes) is not the same as an un-commented no. Programmers are simply wonderful people. [Notice “Programmers”, not “Software Engineers”…]

Troubleshooting: use $ ssh -v -X machinenogui. You’ll see:

When things are working, you’ll see:
debug1: Requesting X11 forwarding with authentication spoofing.
debug1: Sending environment.
And you will have a DISPLAY environment variable set:
$ echo $DISPLAY
machinenogui:10

When things are not working, you’ll see:
debug1: Requesting X11 forwarding with authentication spoofing.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
X11 forwarding request failed on channel 0

And, your DISPLAY variable will be unset:
$ echo $DISPLAY

$

With thanks to : forwarding-request-failed-on-channel-0