LINUX! This word generally invokes the memory of a white-on-black command line terminal in most of us. This notion is partly down to our first experience with the system and partially due to the abundance of these systems used as headless servers. But lately, this fallacy has started to diminish as many users have started to use Linux as their primary drivers using GUI based display.
If you take a quick peek at the new desktop environments available in Linux, you will find many similarities between these and Windows desktop. Desktop environments (DE) like KDE Plasma & Gnome has come a long way since their inception in 1997 and have features compatible (and in some case better) than the Windows desktop environment. But this does not mean both Windows & Linux desktop environments run on the same principles. Linux DE’s are based on the X-windows system commonly referred to that X11.
Enter the X-Windows System (X11)
X11 is an architecture-independent system for remote graphical user interfaces and input device capabilities. The main takeaway here from the definition is its meant for ‘remote’ implementations. Meaning the interface can be accessed by network resources as well. And this is what sets it apart, it enables us to access UI of any application running on a remote Linux machine without any external dependencies like RDP.
As Wikipedia puts it: Unlike most earlier display protocols, X was specifically designed to be used over network connections rather than on an integral or attached display device. X features network transparency, which means an X program running on a computer somewhere on a network (such as the Internet) can display its user interface on an X server running on some other computer on the network.
Unlike the client-server architecture we are used to, the server here is the machine which is being used by the user and the client is the machine where the application is executed. So, any application which is installed on a Linux machine can be accessed by a machine running the X Server. And this is what forms the base of our implementation to access application Gui on remote without using RDP / VNC.
Access GUI using X11 from any machine/OS
As mentioned earlier, GUI of any Linux application can be accessed and interacted with using X11. All Linux desktop environments come preinstalled with all the client-side tools and API’s needed for this connectivity. The only change needed is to enable and configure these options. The following are the quick steps needed:
(Note: For keeping things simple we are going to bypass some security features/commands in the bellow steps. But there are inbuilt features available which you can configure to harden the implementation)
Enable X11 forwarding on Linux
Open the file /etc/ssh/sshd_config using your favorite text editor and uncomment the following lines
There is a plethora of options you can configure in this file like enable forwarding per user basis, etc. But basically, the configuration allows the traffic to be forwarded over to the workstation from this host.
Connect and Run
As mentioned earlier the server component of the implementation resides on your workstation hence implementation varies depending on the operating system you use. But basic steps always remain the same which are:
- Install the X Windows System Server (X display manager)
- Enable X11 forwarding on SSH connection
- Connect using SSH and execute the command to run the program
To run the above in a Linux workstation is extremely simple as it already has a display manager installed.
Connecting using Windows
In case of Windows, we need to install a few programs to make it work. The following provides a summary of steps
- Putty is a client program which helps us to
connect to Linux machines using SSH
- Putty can be downloaded from this location.
- This is a free standalone, portable X Windows
- Xming can be downloaded from this location.
Configure & run Xming
- When you install Xmlng 2 components get installed one is Xlauncher and another is Xming.
- We need to start Xlauncher which is a simple wizard. You can keep all the default configurations and save the configuration.
- Once done you can run Xming. If successful you will notice an “X” icon in the taskbar.
Connect and run the application
- Start Putty and enter the IP address of the Linux host.
- Move to Connection > SSH > X11 section in the ‘Category’ menu of Putty and enable X11 forwarding
- Click open and on console open the application of your choice
- The application will be opened on the screen and you can interact with it like any other application on your workstation.
As you can see this is a very simple yet powerful tool for admins and developers alike. With the advent of application and VM deployment on cloud environments, this can be a very handy tool to manage and control servers without depending on bloated VNC servers or xRDP implementation which can be a pain to configure and maintain.
About Rohan Wadiwala
Rohan is a Solution Architect for MS Stack in Sogeti India Microsoft Practice & Sogeti Europe. He has 13 years of professional experience with 4 years in Architect role covering all aspects of software life cycles on Microsoft & DevOps platform. Rohan is actively involved in absorption of review of new technologies including Docker, Azure, etc. Solution Architecting: Involved in Solution Estimation, RFP response for .Net projects across various industry verticals.
More on Rohan Wadiwala.