SSH to NetBSD 8.2 guest with X11 gives "X11 forwarding request failed on channel 0"

743 Views Asked by At

All,

I'm trying to set up SSH X11 forwarding from a NetBSD 8.2 VM (running via QEMU) to a Ubuntu 20.04 host. When I attempt to ssh -X into the machine, the $DISPLAY variable is not set and I get an error message: "X11 forwarding request failed on channel 0". The following are pertinent environment details:

  • xauth is installed on the NetBSD 8.2 VM and it works properly
  • I have the line ForwardX11 yes in the /etc/ssh/ssh_config file on both NetBSD as well as the Ubuntu host
  • I have the line XAuthLocation /usr/X711/bin/xauth in the ssh_config file on NetBSD.

If I run ssh -v, then the relevant X11 output I get is the following:

Authenticated to localhost ([127.0.0.1]:10022).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: exec
debug1: client_input_global_request: rtype [email protected] want_reply 0
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

what could be possible reasons for this?

1

There are 1 best solutions below

1
On BEST ANSWER

X11 forwarding is disabled by default both in the ssh client and in the sshd server. The setting that controls it in the client is called ForwardX11, and the setting in the server is called X11Forwarding.

When connecting from the Ubuntu machine to the NetBSD machine using ssh, the following configuration files are being used:

  • On the ssh client (Ubuntu machine)
    • ~/.ssh/config
    • /etc/ssh/ssh_config
  • On the sshd server (NetBSD machine)
    • /etc/ssh/sshd_config

With the ssh(1) client, however, you could just use the -X switch instead of editing any of the client configuration files. In fact, I would highly recommend using the -X switch over enabling X11 forwarding for all hosts (i.e. in a Host * block like I'm showing below).

If you do want to edit the ssh client configuration, the ssh_config(5) settings are the ones you already noted:

Host *
  ForwardX11 yes
  XauthLocation /usr/bin/xauth

The default for XauthLocation is already /usr/bin/xauth on Ubuntu, so there should be no need to specify it, unless you have another xauth program installed in another location and you want to use it with ssh.

The sshd(8) server on the NetBSD machine also has to allow X11 forwarding. These sshd_config(5) settings are the ones you still need to change:

X11Forwarding yes
XAuthLocation /usr/X11R6/bin/xauth

Again, the default for XAuthLocation is already /usr/X11R6/bin/xauth on NetBSD 8.2, so there should be no need to specify it.

After changing the sshd_config settings, you also need to restart the sshd service (as the root user):

service sshd restart