Fixing “Can’t Open Display” Error in X11 Forwarding on CentOS: SSH Putty/Xming Configuration Guide


3 views

When attempting X11 forwarding from a CentOS 6 server through SSH with Putty/Xming, you're encountering the classic Can't open display error despite having X11Forwarding enabled in /etc/ssh/sshd_config. This common but frustrating issue typically stems from multiple configuration layers not working in harmony.

First, verify the essential packages are installed:

yum list installed | grep -E 'xorg-x11-xauth|xorg-x11-fonts-*|xorg-x11-utils'

If any are missing, install them with:

yum install xorg-x11-xauth xorg-x11-fonts-* xorg-x11-utils

Edit /etc/ssh/sshd_config to ensure these settings:

X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost no

After modifying, restart the SSH service:

service sshd restart

In Putty's connection settings:

  1. Navigate to Connection > SSH > X11
  2. Check "Enable X11 forwarding"
  3. Set "X display location" to localhost:0.0

After connecting via SSH, verify the DISPLAY variable is set correctly:

echo $DISPLAY
# Should return something like localhost:10.0

Test with a simple X application:

xclock &

Check if the firewall is blocking X11 connections:

iptables -L -n | grep 6010
# If no output, add a rule:
iptables -A INPUT -p tcp --dport 6010 -j ACCEPT
service iptables save

If traditional X11 forwarding proves problematic, consider X2Go:

# On CentOS 6:
wget -O /etc/yum.repos.d/x2go.repo http://packages.x2go.org/epel/x2go.repo
yum install x2goserver x2goserver-xsession

For detailed troubleshooting, connect with:

ssh -vvv -X user@your_server

Check X11 authentication:

xauth list

For newer systems, consider these alternatives:

  • VNC server setup
  • NoMachine NX
  • Dockerized X11 solutions

When attempting X11 forwarding from a Windows 10 machine (using Putty 0.78 with Xming 6.9.0.31) to a CentOS 6 x32 Linode VPS, the connection establishes but graphical applications fail with:

Error: Can't open display: :0.0
X11 forwarding request failed on channel 0

First confirm these essential components:

# On CentOS server:
rpm -qa | grep -E 'xorg-x11|xauth'
yum list installed | grep -i xorg

# Expected output should include:
xorg-x11-xauth-1.0.2-7.1.el6.i686
xorg-x11-server-utils-7.5-6.el6.i686

Edit /etc/ssh/sshd_config with these exact parameters:

X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost no
AddressFamily inet

Then restart SSH service:

service sshd restart

In Putty configuration:

  1. Connection > SSH > X11: Enable "X11 Forwarding"
  2. Set "X display location" to localhost:0.0
  3. Under SSH > Auth: Enable "Allow agent forwarding"

After SSH login, verify these variables:

echo $DISPLAY        # Should show localhost:10.0
xauth list           # Should display MIT magic cookies

On CentOS 6, modify iptables:

iptables -I INPUT -p tcp --dport 6000:6010 -j ACCEPT
service iptables save

Try these diagnostic commands:

# Test basic X functionality:
xeyes -display $DISPLAY

# Verbose X11 debug:
ssh -vvv -X user@host xclock

If standard X11 forwarding fails, consider:

ssh -Y user@hostname   # Uses trusted X11 forwarding

As last resort, reinstall critical packages:

yum reinstall xorg-x11-xauth xorg-x11-fonts-* xorg-x11-utils -y