Fix “X11 forwarding request failed on channel 0″
First of all, we assume that you already enabled X11 forwarding over SSH properly.
If you are getting “X11 forwarding request failed on channel 0” message upon SSH login, there could be several reasons. Solutions vary as well.
For security reason, OpenSSH server, by default, binds X11 forwarding server to the local loopback address, and sets the hostname in DISPLAY environment variable to “localhost”. Under this setup, some X11 clients cannot handle X11 forwarding properly, which causes the reported error. To fix this problem, add the following line in /etc/ssh/sshd_config file, which will let X11 forwarding server bind on the wild card address.
Restart SSH server to activate the change:
$ sudo systemctl restart ssh.service (Debian 7, CentOS/RHEL 7, Fedora)
$ sudo service sshd restart (CentOS/RHEL 6)
The broken X11 forwarding error may also happen if the remote host where SSH server is running has IPv6 disabled. To fix the error in this case, open /etc/ssh/sshd_config file, and uncomment “AddressFamily all” (if any). Then add the following line. This will force SSH server to use IPv4 only, but not IPv6.
Again, restart SSH server to finalize the change.