X11 forwarding request failed on channel 0 error under Linux

  
                

When you use the X11 forwarding option of SSH to connect to the remote connection, you may encounter an error when logging in, X11 forwarding request failed on channel 0” (X11 forwarding request failed on channel 0) What is the cause of the error? How to solve it? The following small series teaches you how to deal with this problem under Linux.

First, let's assume that you have properly enabled X11 forwarding for SSH.

If you encounter when you log on & ldquo; X11 forwarding request failed on channel 0 & rdquo; (X11 forwarding request failed on channel 0), there may be different reasons, and the solution is different.

Option One

For security reasons, OpenSSH service by default X11 forwarding the request to bind to the local loopback address, and is set to & ldquo in the DISPLAY environment variable in the host name; Localhost”. With this setting, some X11 clients cannot handle X11 forwarding correctly, which can lead to errors in the report. To solve this problem, add the following lines to the /etc/ssh/sshd configuration file, which binds the X11 forward request to the external network card address.

$ sudo vi /etc/ssh/sshd_config

X11Forwarding yesX11UseLocalhost no

Restart SSH for the settings to take effect:

$ sudo /etc/init.d /ssh restart (Debian 6, Ubuntu or Linux Mint)$ sudo systemctl restart ssh.service (Debian 7, CentOS/RHEL 7, Fedora)$ sudo service sshd restart (CentOS/RHEL 6)

Scenario 2 Br>

If the remote host's SSH service disables IPv6, an X11 forwarding failure error may also occur. To solve the error in this case. Open the /etc/ssh/sshd configuration file and uncomment the “AddressFamily all" (if there is one). Then join the following line. This forces the SSH service to use only IPv4 instead of IPv6. (LCTT Annotation: There may be errors here, AddressFamily does not have this parameter, and any means support both IPv6 and IPv4. In this scenario, it should be to disable IPv6 support, only IPv4, so it should be " Comment out AddressFamily any” is right.)

$ sudo vi /etc/ssh/sshd_config

AddressFamily inet

The above is the repair under Linux<X11 forwarding request failed on Channel 0” The wrong method is introduced. There are many reasons for this error. Different situations are handled differently. The current mention is that you have enabled X11 forwarding of SSH correctly.

Copyright © Windows knowledge All Rights Reserved