This post may contain affiliate links/ads and I may earn a small commission when you click on the links/ads at no additional cost to you. As an Amazon Affiliate, I earn from qualifying purchases. Techsphinx also participates in the StationX Affiliate program. You can read my full disclaimer here.
In this guide, I will show you how to enable X11 Forwarding over SSH on Raspberry Pi and access remote graphical applications from Windows and Linux.
SSH (Secure Shell) protocol enables a user to connect to a system and perform tasks on it remotely. However, SSH only provides access to the shell, this means you can only use the command-line interface (CLI) to perform tasks on the remote system.
So, what if you need to open any GUI (Graphical user interface) application? This is where X11 forwarding comes to play.
X11 forwarding allows a user to forward the remote application display to the client machine. After you enable X11 forwarding on Raspberry Pi, you can start any GUI application and forward its graphical interface to the client device.
- Raspberry Pi (Pi 3 or 4 recommended)
- Power Supply
- Micro SD Card (32 GB Recommended)
- SD Card Reader
- Micro HDMI (For Pi 4) or HDMI Cable (For Pi 3 and below versions) [Optional]
Alternatively, you can purchase CanaKit Raspberry Pi 4 Extreme Kit that contains all the above-mentioned items.
Pre-Requisites to enable X11 forwarding on Raspberry Pi
- Raspberry Pi OS installed and running.
- Active internet connection to download the required software.
- Sudo privileges on Raspberry Pi and the client Linux Machine.
- SSH service enabled on Raspberry Pi.
If you don’t know how to enable SSH, then you can check out my guide on “how to enable SSH on Raspberry Pi” before proceeding.
Setup X11 Forwarding on Raspberry Pi
You don’t have to install any package to use the X11 window forwarding. You just have to enable the X11 Window Forwarding in the SSH config files.
On Raspberry Pi OS, X11 Window Forwarding is enabled by default. If it is not in your case, then follow the below steps to enable it:
1. Open the terminal.
2. Open the “sshd_config” file. I am using the Nano command-line text-editor to open and edit the file.
sudo nano /etc/ssh/sshd_config
3. Find the line that says “X11 forwarding”, uncomment the line (remove # from the beginning) and make sure it is set to “yes”.
4. Save and close the file. In Nano, use the Ctrl + x key combination to exit the file and when it asks to save choose “yes”.
5. Restart the SSH service.
sudo systemctl restart ssh
That’s it, X11 Window Forwarding is now enabled on your system.
Connect to Raspberry Pi via X11 Forwarding
You can connect to Raspberry Pi using X11 forwarding from Windows and Linux.
Connecting from Windows
You’ll need 2 tools to connect to Raspberry Pi via the X11 Window Forwarding – PuTTY and Xming
2. Launch Xming, then launch PuTTY and fill in the IP address of the Raspberry Pi.
3. Now, navigate to Connection > SSH and enable the X11 Window Forwarding.
4. Click on the “Open” button, and a new PuTTy session will be opened.
5. Log in to the Raspberry Pi by providing the username and password of any user on the Pi. I am using the default “pi” user here.
6. Now, you can open an X session of any program. Just type the name of the program that has a graphical user interface (GUI).
To run VLC media player run the command:
To start Thonny Python IDE run the command:
Connecting from Linux
To connect from Linux, you don’t need to install any programs, the ssh client is pre-installed on most Linux systems. Just use the “-X” option for an X-window session.
ssh -X [email protected]
(Replace USER and IPADDRESS with the actual username and IP address of Raspberry Pi)
Once, you are connected via SSH, you can run any graphical application on Pi and the screen will appear through the X11 Window forwarding.
Just type the name of the program that has a graphical user interface (GUI).
To run VLC media player run:
To start Thonny Python IDE run:
Other ways to connect to Raspberry Pi Remotely
There are other ways to remotely connect to Raspberry Pi apart from using the X11 Window Forwarding over SSH. I have written various guides for the same.
Here are links to those guides:
You can use any of these utilities or protocols to remotely connect to the Raspberry Pi.
That’s it for connecting to Raspberry Pi via X11 Forwarding over SSH. If you have any questions, then feel free to ask them in the comments.
Also, you can check out my other articles/guides related to Raspberry Pi here.