X11forwarding is a powerful feature of SSH that enables users to run graphical applications on a remote server while displaying the interface on their local machine. This tutorial will guide you through the process of setting up X11forwarding, ensuring you can seamlessly interact with graphical applications on a remote server.
Step 1: Install and Start an X Server on Your Local Machine:
- Linux: Most Linux distributions come with X11 server installed by default. If not, install package “
xorg” using your package manager.
- macOS: Download and install XQuartz from XQuartz website.
- Windows: Download and install Xming from Xming website.
Step 2: Enable X11 Forwarding in Your SSH Server:
In the “
/etc/ssh/sshd_config” file on the remote server, make sure you have the following line uncommented and set to “
Yes” to ensure X11forwarding is allowed:
After you have confirmed that X11forwarding is enabled restart ssh server service.
sudo systemctl restart ssh
Step 3: Connect to the remote ssh server with -Y or -X option for X11Forwarding:
-X option sets up X11 forwarding with a higher level of security. When you use
-X, it enables X11 forwarding but restricts the permissions that the remote X11 client has on your local machine. This means that the remote X11 client can’t easily capture or manipulate your local X11 server’s data.
ssh -X username@remote_server_ip
-Y option is similar to
-X but relaxes some of the security restrictions. It allows the remote X11 client more permissions on your local X11 server. While this option can be more convenient, it also introduces some security risks. It is essential to use it only when connecting to trusted servers.
ssh -Y username@remote_server_ip
After connecting to the remote server successfully, test X11forwarding by running a graphical application. Remember before attempting to use X11forwarding, ensure that the X Server application installed in “Step 1” is running on your local machine.
This should get you started with X11 forwarding. Enjoy running graphical applications on your remote server while the display is shown on your local machine!