Home Company Services Mock exams Contact us

  Home
  Company
  Services
  Mock exams
  Tools
  Contact us

 X11 forwarding over ssh tunnel

There are situations when we need to start a remote X11 client over an ssh tunnel. Below you will find two possible scenarios.

Scenario 1: single hop connection - the client can reach the server directly. See fig.1


Fig. 1
 

In this scenario, the Desktop is running the X11 server. If Desktop is a windows workstation, X11 server can run over cygwin or exeed. On the client side (Server A) let's assume, for simplicity, that the X11 client is mozilla. To export mozilla from Server A to Desktop, you should follow the steps below:

On Desktop:
        start cygwin
        startx          (start X11 server on Desktop)
        xhost +ServerA  (allow X11 clients from ServerA to connect to Desktop)
        ssh -R 6000:kuxonorg.dot5hostingmysql.com:6000 myuser@ServerA (forward requests comming to kuxonorg.dot5hostingmysql.com (on ServerA) port 6000 to Desktop port 6000)

On ServerA:
        export DISPLAY=kuxonorg.dot5hostingmysql.com:0 (set the DISPLAY environment variable to locahost, ID 0)
        mozilla (start X11 client)

As a result, the X11 client should be displayed on Desktop through the ssh tunnel.

Scenario 2: multi hop connection - the client can't reach the server directly, extra steps are involved. See fig. 2


Fig.2


In this scenario, as in the single hop situation, the Desktop is running X11 server. ServerA has no other role than to allow access to the network where ServerB resides. Desktop and ServerB are on different networks. On the client side (Server B) let's assume, for simplicity, that the X11 client is mozilla. To export mozilla from ServerB to Desktop, you should follow the steps below:

On Desktop:
        start cygwin
        startx          (start X11 server on Desktop)
        xhost +ServerA  (allow X11 clients from ServerA to connect to Desktop)
        ssh -R 6000:kuxonorg.dot5hostingmysql.com:6000 myuser@ServerA (forward requests comming to kuxonorg.dot5hostingmysql.com (on ServerA) port 6000 to Desktop port 6000)

On ServerA:
        ssh -R 6000:kuxonorg.dot5hostingmysql.com:6000 myuser@ServerB (forward requests comming to kuxonorg.dot5hostingmysql.com (on ServerB) port 6000 to Desktop port 6000)
On ServerB:
        export DISPLAY=kuxonorg.dot5hostingmysql.com:0 (set the DISPLAY environment variable to locahost, ID 0)
        mozilla (start X11 client)

At this time, the X11 client should be displayed on Desktop through the ssh tunnel chain.
If there are more hops involved, repeat step "ServerA" on each intermediate box.