How to configure X11 forwarding over SSH in AlmaLinux

almalinux x11 forwarding

This solution applies to CentOS 5, 6, 7, 8, 9 and gives details of a minimal number of packages for an X11 environment to support X forwarding.


Setting up the SSH server (X11 forwarding source)

  • Install the following packages as root.
xorg-x11-xauth
xorg-x11-fonts-*
xorg-x11-utils
dbus-x11
# dnf install -y xorg-x11-xauth xorg-x11-fonts-* xorg-x11-utils dbus-x11
  • For older OS.
# yum install -y xorg-x11-xauth xorg-x11-fonts-* xorg-x11-utils dbus-x11

Setting up the SSH client (X11 forwarding target)

  • set X11Forwarding to true in /etc/ssh/sshd_config.
  • Install a full GUI on the client system
  • Start a GUI session on the system
  • Open a GUI-based terminal on the system
  • Start the SSH session with the -X option. Run the command ssh -X $HOST where $HOST is the address of the SSH server.
  • After SSH session starts, GUI applications run in the SSH session should appear on the client system.

Testing

  • Install the xterm package on the SSH server.
# yum -y install xterm

or

# dnf -y install xorg-x11-apps
  • From the client system connect to SSH server using the -Y parameter.
$ ssh -Y user@192.168.0.1
  • Run the xterm command
$ xterm
  • If an xterm window displays, the configuration is working properly.