SSH X11 forwarding is on
- Check
ssh.x11_forwarding- Severity
- low
- Runs
- on the server, in the daily run of the agent
- Looks at
- X11Forwarding is yes
What the check looks at
X11Forwarding in the effective sshd configuration (sshd -T). The check warns when it is yes, also inside
a Match block.
Risk
A server without a desktop does not use X11 forwarding. While it is on, sshd starts an X11 proxy for every session that asks for one: more code that can have bugs. A client that forwards its display to a compromised server exposes that display (ssh(1) warns about this). The severity is low; turning it off is cleanup.
The OpenSSH default is no, but we found X11Forwarding yes in /etc/ssh/sshd_config on Debian 12, Debian 13
and Ubuntu 24.04, and in /etc/ssh/sshd_config.d/50-redhat.conf on Rocky Linux 9 and 10. Alpine 3.24 ships
no.
How to fix it
Add a drop-in file. sshd keeps the first value it reads and reads the files in /etc/ssh/sshd_config.d/ in
alphabetical order before the rest of sshd_config, so a name that starts with 10- wins over the setting of
the distribution. On RHEL 8, Rocky Linux 8 and AlmaLinux 8, sshd_config does not read
/etc/ssh/sshd_config.d/; add the Include line at the top of it first, as the
SSH hardening guide shows.
echo 'X11Forwarding no' | sudo tee /etc/ssh/sshd_config.d/10-x11.conf
sudo sshd -t
On RHEL, Rocky and Alma, leave 50-redhat.conf as it is: a package update can replace it, and the 10- file
is read first.
Reload sshd.
Debian and Ubuntu
sudo systemctl reload ssh
RHEL, Rocky Linux and AlmaLinux
sudo systemctl reload sshd
Alpine
Alpine ships no. If someone turned it on, remove that line and run sudo rc-service sshd reload.
How to check the fix
sudo sshd -T | grep '^x11forwarding'
The output must be x11forwarding no.
When a warning is fine
When people run graphical tools on the server over SSH on purpose, such as a GUI installer or a plotting tool.
Keep it on for them only, with a Match block:
X11Forwarding no
Match Group x11-users
X11Forwarding yes
Sources
- sshd_config(5) (
X11Forwarding, defaultno;Match) - ssh(1) (the risk for the client)