Running GUI programs both locally and on remote systems through SSH
Part 1: Running a Graphical Application on a Remote System
In this blog post, we will explore how to run a graphical application on a remote system using the command "$DISPLAY=:0 application_name". Running graphical applications remotely can be useful in scenarios where the user wants to utilize the processing power of a remote system while interacting with a GUI application. This method allows users to run resource-intensive applications on powerful servers or virtual machines, providing a seamless graphical experience.
Step 1: SSH into the Remote System To begin, we need to establish an SSH connection to the remote system. Open a terminal on your local system and use the following command:
ssh username@remote_system_ip
Replace "username" with your actual username on the remote system, and "remote_system_ip" with the IP address or hostname of the remote system.
Step 2: Run the Graphical Application With the display variable set, you can now run any graphical application as if it were running on the remote system's local display. For example, to launch the "firefox" , use the following command:
DISPLAY=:0 firefox
The "firefox" window will appear on your local system, but the application is actually running on the remote system.
Part 2: Running GUI Programs on local system Through SSH with X11 Forwarding
In this second part of the blog, we will explore another method of running GUI programs on local system through SSH using X11 forwarding. X11 forwarding allows the remote system to forward graphical data to your local system securely.
Step 1: Enable X11 Forwarding on the Remote System Before using X11 forwarding, ensure it is enabled on the remote system. Open the "/etc/ssh/sshd_config" file on the remote system with a text editor, and ensure the following line is uncommented:
X11Forwarding yes
Save and close the file, then restart the SSH server to apply the changes:
sudo systemctl restart sshd
Step 2: SSH into the Remote System with X11 Forwarding To use X11 forwarding, SSH into the remote system with the "-X" option:
ssh -X username@remote_system_ip
Step 3: Run the Graphical Application Once logged in with X11 forwarding, you can run graphical applications just like in Part 1. For example, to launch the "firefox" :
firefox
The "firefox" window will now appear on your local system, but the application is running on the remote system with X11 forwarding.
Conclusion: In this blog post, we explored two methods of running graphical applications on remote systems. The first method involved running the application directly on the remote system's local display. The second method utilized X11 forwarding, which allowed graphical data to be forwarded securely from the remote system to the local system. Both methods provide flexibility and efficiency for running graphical applications on remote systems, enabling users to harness the power of remote resources while enjoying a seamless graphical experience.