Peter's Blog

Redefining the Impossible

Items filed under x


Xming is an X server for Windows. With it one can run linux applications on a remote linux box with the X user interface windows appearing on ones Windows desktop:

xming demo

xming demo

Internet Explorer, xeyes and xterm in perfect harmony.

How to do this wonderous thing?

  • install xming
  • run xlaunch to fire up xming as your windows X server (should be added to quick launch), selecting the following options:
    • Multiple Windows (each app gets its own windows window)
    • Display Number 0
    • Start no Client (client is the program that runs)
    • No Access Control (I'm a trusting soul)
  • you now have an X server on your windows box as display :0. An X server is something that displays the user interface for X client programs (X keeps you on your toes by using counter-intuitive terminology).
  • open putty at the configuration of your favourite linux box.
  • enable the X forwarding option:
    X forwarding in Putty

    X forwarding in Putty

    the 127.0.0.1:0 means remote X clients will display on your new windows X server (:0) running on your pc (127.0.0.1)
  • open the ssh connection in putty and enter a command such as xterm. Amazingly, an xterm window should open on your local pc! It's wonderous, xterm is running on the remote pc but the user interface is on your windows box.

Interestingly, the ssh session you open has a DISPLAY environment variable open that tells the X clients you launch from it where to stick their displays.

peter@server:~$ echo $DISPLAY
localhost:10.0
peter@server:~$

Through the miracle of ssh this is routed back to xming on the Windows box.

Now, how about if beyond your gateway ssh server is another ssh server and you want to run your X client applications on that? The answer is amazingly simple. Open the session on the gateway server as described above and then use the command:

ssh -X name-of-other-server

you now have a command prompt on the remote remote server and if you now run

xterm

then again you get a xterm display coming up on your local windows pc but this time from the remote^2 box.

UPDATE: troubleshooting

  • may need this in /etc/ssh/sshd_config
    X11UseLocalhost yes
    
  • may need to
    sudo apt-get install xauth
    
    I needed this on a previously x-less box where I had installed gitk to do some git study on a headless server box

Filed under: putty ssh x xming


Just got X going over ssh again, so a reminder to self on how I did it:

  • make sure
    X11Forwarding yes
    
    is in /etc/ssh/sshd_config at the server end
  • then, in client:
    ssh -X -2 user@server
    
    • -X means X forwarding
    • -2 forces v 2 ssh protocol
  • this should give you a remote terminal. In it start whatever application, e.g.
    xclock &
    
    this will be running on the remote system but will display locally.
  • if you get the error "cannot connect to X server localhost:10.0" then you need to do
    xhost +
    
    in a local terminal: the error means the remote app cannot open an X window on your local system, xhost + releases this.

Filed under: linux ssh x

3 Comments