X11(also known as Xorg Server) is the display system for Linux. The technology has been around since the mid-80s and was designed during a time when personal computers were coming into the mainstream.
Without getting into a history lesson, X11 is essential for all Linux users, even to this day. It makes the graphical interface work and is very important for most day-to-day operations, etc.
Aside from its ability to handle graphics cards and render the desktop on Linux, one of the best features of X11 is the fact that it can display a graphical interface over a network via X11 forwarding. In this tutorial, we’ll show you how to set up X11 forwarding on Linux over SSH.

Prerequisites

In order to use X11 forwarding on Linux, you must have SSH set up. The reason SSH is required is that X11 forwarding is a feature of Secure Shell, and there’s currently no way to take advantage of this feature outside of SSH.

Setting up an SSH server is quite easy, and most Linux distributions make it little more than a one or two step process. To set it up, open up a terminal window and install the SSH client on the computer connecting out. With the client installed, move to the remote computer or server and install the SSH server package, and enable the systemd services to start using it.

Unsure about how to install and use the Secure Shell server on Linux? We can help! Check out our tutorial on setting up SSH. It goes over how to set up connections, and even some common command examples!

Enable X11 forwarding

Enabling the X11 forwarding feature in SSH is done within the SSH configuration file. The configuration file is /etc/ssh/ssh_config, and must be edited with sudo or Root user access. Open up a terminal window and run the superuser login command. If you can’t use su because your system has it disabled, replace it with sudo -s to log into the Root account that way.

su -

or

sudo -s

The terminal now has Root access, so it’s safe to open up ssh_config with the Nano text editor. In a terminal, open up ssh_config in the Nano text editor tool.

nano -w /etc/ssh/ssh_config

Scroll through the Nano text editor using the Up/Down arrow keys, locate the line that says “ForwardX11” and remove the comment symbol (#) from in front of the code.

Note: If you can’t find the X11 forwarding line in the ssh_config file, press Ctrl + W in Nano to bring up the search feature. Then paste in “ForwardX11” and press Enter to jump to the line of code in the configuration file.

After making the edits to the SSH server configuration file, press the Ctrl + O keyboard shortcut to save the edits you’ve made. Close the Nano editing tool with Ctrl + X.

Reset the SSH server

Now that the X11Forward line is turned on in the SSH server configuration file, the SSH server software must reboot, as configuration changes don’t happen right away. For most Linux distributions, resetting SSH involves using the systemctl restart command.

Note: Linux distributions that do not use systemd have their own restart mechanism for SSH. If you can’t figure out the command to reboot your Secure Shell server software, the next best thing is to reboot the machine. Configuration changes will start working after booting back up.

systemctl restart sshd.service

When the SSHD background service comes back up, your SSH server will be ready to forward X11 windows over the network.

Use X11 forwarding

X11 forwarding is a feature of SSH, not it’s own thing. To use it, write in an SSH connection command like the one below.

Note: replace remoteuser and remote-hostname with the remote username and remote hostname or IP address

ssh remoteuser@remote-hostname -X

If your SSH server runs on a port that isn’t the default port i.e., port 22, you will need to specify it in the connection command. Try the following command example to make a successful connection.

ssh remoteuser@remote-hostname -X -p portnumber

Once a successful SSH connection is made to the remote machine, you can remotely forward applications installed on the server to your computer’s desktop by running the program from the terminal.

For example, to launch the version of Gedit installed on the SSH server, you’d run the gedit command.

gedit

For the Nautilus file manager, you can run the nautilus command.

nautilus

Need to launch more than one program over SSH and X11 forwarding? You’ll need to open multiple SSH connections and work from each of them.

Closing forwarded programs

To close an open application forwarded over SSH, you can press Ctrl + C, or click the “close” button like any other program on your computer.

Read How to set up X11 forwarding on Linux by Derrik Diener on AddictiveTips - Tech tips to make you smarter



from AddictiveTips http://bit.ly/2AbiWF5
via IFTTT