SSH X Server Forwarding

Preface

In some situations it is required as well on Linux/UX server to run standard X Windows Server environment to start some application that do not fully support CLI interface.

On another hand it is possible that you will need to run the X Windows GUI only at installation of the application and then not any more. According to this you are asking why I shall install the whole X Windows and then KDE, GNOME, XFCE,… .

To be honest you really do not need to install this. It is enough to run X Windows Server on your SSH Client site so that you can forward Unix socket to your SSH Server. In this way your SSH Server will be able to start any application requiring X Windows Server with using tunneled X Windows Server socket. The whole application will run on the SSH Server only the GUI will run on your SSH Client.

Required configuration

Please make sure that on your SSH Server you have installed:

xauth    #X authority file utility

In “ /etc/ssh/sshd_config ” please enable (and restart sshd):

X11Forwarding yes
X11DisplayOffset 10

Starting SSH X Server Forwarding

Description: “ -X # Enables X11 forwarding. “
Example: “ ssh -X user@server_IP ”

or

Description: “ -Y # Enables trusted X11 forwarding. “
Example: “ ssh -Y user@server_IP ”

ssh –X user@server_IP
# Application running on SSH Server using SSH X Server Forwarding is treated as an untrusted client.
According to this SSH Client sends a command to the remote machine and receives the graphical output. If your command violates some security settings you'll receive an error instead.

ssh –Y user@server_IP
# Application running on SSH Server using SSH X Server Forwarding is treated as an trusted client.
This option can open security issues, because other GUI (X11) client could sniff data from the remote machine and it is even possible to alter those data.

Check availability of X Server on SSH Server

[root@SSH_Server ~]# echo $DISPLAY                                    # We do not have configured any socket for X Server

[root@SSH_Server ~]#

Establish connection

[user@SSH Client ~]$ xhost +                                            # Configure local X Server to accept conection

[user@SSH Client ~]$ ssh -X user@SSH_Server                             # Open SSH connection with X Server Forwarding
Last login: Sat Jan 25 17:59:01 2014 from SSH_Client
[user@SSH_Server ~]$

Check availability of X Server on SSH Server (with SSH X Server Forwarding)

[root@SSH_Server ~]# echo $DISPLAY                                    # We do have configured any socket for X Server
localhost:10.0
[root@SSH_Server ~]#

Start X Server Application

[root@SSH_Server ~]# xclock                                           # You shall be able to see application GUI on your SSH Client
Navigation
Print/export
QR Code
QR Code wiki:infrastructure_tools:ssh:ssh-x-server-forwarding (generated for current page)