Unable to Run X Applications Through SSH in Linux

The Problem

The user is unable to run X applications through SSH on a CentOS/RHEL system. The following message is displayed:

# xclock
Error: Can't open display:

The Solution

1. X11 forwarding is disabled on SSH login unless “-X” option is specified:

# ssh -X user@address

2. It may have been disabled in “/etc/ssh/sshd_config” with the below setting:

# vi /etc/ssh/sshd_config
...
X11Forwarding no
...

3. Please make sure X11 forwarding is enabled in “/etc/ssh/sshd_config”:

# vi /etc/ssh/sshd_config
...
X11Forwarding yes
...

Then, use the “-X” option while logging in.

Related Post