When connecting to a remote Linux server via SSH, graphical applications cannot be displayed locally unless X11 forwarding is properly configured on both the client and the server side.
/etc/ssh/sshd_config on the server (or access to a sudoer account).Ensure that the SSH client has the X11 forwarding option enabled before connecting.
Edit /etc/ssh/sshd_config and ensure the following directive is present and not commented out:
X11Forwarding yes
Restart the SSH daemon after any change to this file:
sudo systemctl restart sshd
Once connected with X11 forwarding active, grant the target OS user access to the current X display:
sudo -u <os_user> xauth add `xauth list $DISPLAY`
Confirm that the DISPLAY environment variable is correctly propagated for the target user:
sudo -u <os_user> echo $DISPLAY
Expected output example: :10.0 or localhost:10.0.
Launch a minimal X application to confirm the full chain is working:
sudo -u <os_user> xterm
An xterm window should open on the local desktop.
| Check | Expected Result |
|---|---|
X11Forwarding yes present in /etc/ssh/sshd_config
|
Directive uncommented and set to yes
|
echo $DISPLAY for target user |
Returns a non-empty value such as localhost:10.0
|
xterm launches |
A terminal window appears on the local X display |
DISPLAY is empty: the SSH session was not started with X11 forwarding enabled. Reconnect using ssh -X user@host or enable the option in the client.xauth command not found: install the xauth package (dnf install xorg-x11-xauth on RHEL/Rocky).xterm command not found: install the xterm package (dnf install xterm).