Tuesday 5 April 2016

Setting up and using X Forwarding

SSH provides the ability to stream X sessions over it, allowing remote administrators to access a desktop environment without having to logon to the console.

Firstly on the machine we wish to stream - we should ensure X11 forwarding is enabled within the SSH daemon configuration:

sudo nano /etc/ssh/sshd_config

and ensure the following line is present / uncommented:

X11Forwarding yes

We should also ensure that the user we will be connecting as has the ability to launch X sessions (otherwise we might be something like: X: user not authorized to run the X server, aborting.) - this is defined within /etc/X11/Xwrapper.config.

sudo nano /etc/X11/Xwrapper.config

There are three available values - root, anybody and console - of which often it is set to console only - so as we are performing this remotely we will need to set it to anybody.

Now on the remote machine we should ensure that the SSH client is configured to allow X11 forwarding:

sudo nano /etc/ssh/ssh_config

and ensure the following is present / uncommented:

Host *
ForwardX11 yes
ForwardAgent no

(You should ideally specify the specific host, rather than using astrix to tighten up security.)

and then SSH to the host running X11 (using the -X switch):

ssh -X user@

Once logged in - simply issue startx at the prompt!


Post a Comment