Note: Because this is an ongoing series, there is no certificate of completion available for this course.
Skill Level Intermediate
- [Instructor] Many applications we might use remotely thorough SSH have text interfaces, and a text terminal makes it easy to run those. But some applications have graphical interfaces, so how do we use those across the network? Well, we could set up a VNC server, and transmit our whole desktop screen session across the network. Or we could take advantage of a feature of SSH called X11 forwarding. X11 is a technology that draws graphical interfaces on a UNIX or Linux system. When we use a Linux desktop environment, what we're seen is drawn by the local system's X11 software, called the X Server, or the X.org server on the local display.
But we can also use X to draw GUI windows on a local machine for software running on a remote machine across the network, through SSH. Using X11 forwarding, the application looks as through it's running locally. You can reposition and resize the window and minimize or maximize it. But, when it comes to data access, like network or file usage, everything happens on the remote system. The software has access to the remote file system, not the local file system, and network activity and processing happen on the remote system as well. All we really have on the local system is the interface of the software.
That makes X11 forwarding helpful for using software that needs a lot of resources on the backend, or accessing software you don't want to have installed locally, for whatever reason. The interface can be a little slow, however, since it's being routed over SSH instead of being drawn on the system that's running the software. To use X11 forwarding, typically we'll use SSH with the -X option, and then we'll give it the credentials to connect. If we connect like this we'll get a shell, anything that I run in the shell that has a GUI will have the interface forwarded to the local machine.
I'll open up Firefox. This instance of Firefox is running on that remote machine, but I see it's interface here on my local machine. In fact, if I open up the system monitor, I can see that Firefox isn't running on this local machine. And, up here in the menu bar, I can see that this is running on the other computer. In this Firefox instance, when I load a webpage the remote system requests the information from a web server, it receives it, and then passes it to the part of its code that renders the webpage.
Then, on the local machine, we see the interface update, with the webpage in the window. In order to use a remote X session, the remote system that's running the software needs to have X Server installed, as does the local machine. While X11 forwarding is pretty well supported on Linux, you can also use it on Mac and Windows clients with some additional software. On a Mac you need to install a package called XQuartz, which provides the X11 framework. And on Windows, PuTTY can forward X11 services, but it needs an X Server like Xming installed.
X11 forwarding offers one way of using applications on a remote system. Depending on your use case, and your organization's security policies, it can be a useful tool in your workday.