X11 Forwarding Request Failed on Channel 0

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

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

X11 Forwarding Error on Ubuntu, Though It Works On Windows

I solved it - it was an authentication issue. Executing the following line on Server resolved the issue:

$ xauth add ${client_ip}:0 . ${hex_key}
xauth: creating new authority file /homes/${username}/.Xauthority

where ${client_ip} is the client with X server running, ${hex_key} is the 32-character hex string. Afterwards upon assinging the $DISPLAY env variable I can now connect successfully.



Related Topics



Leave a reply



Submit