X-Forwarding using SSH

Ever wondered to get a GUI application from another machine get rendered onto yours? If not, Linux offers that to you :P Let's see how: First of all we shall discus some basic terminologies before moving ahead:

The display server

The display server is very similar to a web-server. So Imagine that you have an apache server. Now when a client requests a service, the server would send a few instructions accordingly to the client over http/https protocol. The client(which here is the web browser) will render those instructions and display the content requested. The display server in Linux works almost the same way. The server here interacts with the hardware (CPU) and sends instructions over a protocol known as the 'X' protocol. The latest version of the same is 11, and hence it's called X11.

X-Forwarding

Think what would happen if the display-server is on one machine and client on the other machine? Yes! that would render the graphical applications onto the client machine. That's is exactly what X-forwarding is – render the application on one machine while it runs on a different machine.

Okay, enough of terminologies, let's get to implementing it now.

On the server, configure /etc/ssh/sshd_config to contain the following:

X11Forwarding yes
X11DisplayOffset 10

These two are usually commented out, ensure that the sshd_config contains these. You may need to restart ssh for the changes to be picked up. You can run this if the ssh server doesn't pick that up and then restart the server:

cat /var/run/sshd.pid | xargs kill -1

Next, start ssh on both the machines. On Debian or Debian derivatives you can do so by doing:

sudo service ssh start

Now we will connect the client to the server. On the client machine type:

ssh -X <server name>@<server ip>

If you are facing trouble finding out ip, you can do so via:

nmcli -p device show

And it's done! You have SSH'd into the server machine. Now you can render GUI apps on the client machine, while it runs on the server.

firefox

Here's me rendering firefox on the client :D