While X11 remains the foundation for most Linux desktops, its network transparency, or ability to display output across the network, is one of its unsung features. SSH makes it easy and secure to run Linux GUI apps on a remote machine and display them on your machine.

Why Run Linux Apps Remotely?

Why would you want to run a graphical Linux program on another machine? If you were using a complex scientific computing program like R or Mathematica, you can run it on a heftier machine while still using a lightweight computing environment locally, such as on a Chromebook.

It's also a great way to share technical applications among multiple users by installing them on a central server.

Authorizing X Connections on the Server

To enable X11 connections over SSH, you'll have to enable X11 forwarding on the remote server. This is done using the /etc/ssh/sshd_config file.

/etc/ssh/sshd_config file on Arch Linux edited to enable X forwarding

You would have to open this file as the root user to edit it. Scroll down to the "X11Forwarding" option and change it to "yes" if it's not enabled already. To restart the SSH server, use the systemctl command:

        sudo systemctl restart sshd
    

You may also need to remove a leading "#" comment character to activate it. Once done, save the file and start the OpenSSH server if it isn't already running. If you're not the administrator, you may have to ask the admin to do this for you.

Running Graphical X Apps Remotely Using SSH

X-Apps-over-SSH

To run your X apps remotely, log in to the remote server over SSH with the -X option, which will enable X forwarding on the client end.

        ssh -X username@server
    

To run your programs, call them from the command line as if you were sitting at a desktop Linux system. If all goes well, you should see the program appear on your desktop, even though it's running somewhere else.

Because X forwarding is slow, it might take a while from when you run the command to when the window opens up. If you need a full desktop or want to run apps faster, you might want to look into another remote display solution like VNC.

If you run into problems, try using the -Y option instead of -X. This will disable some security checks but still allow you to run X apps over SSH. Failing that, make sure that X forwarding is enabled on the remote machine as mentioned above.

Now You Can Run Linux Apps Over SSH

SSH X forwarding makes it easy to run Linux GUI apps remotely. It shows how network-oriented Linux is because you can use remote systems just as if you were sitting right at the keyboard and screen, no matter where you are. Once you have SSH set up, secure remote logins are a snap.