Windows, Putty & X

Posted by mwguy on Tue 13 August 2013

This is a howto on using Xserver applications via SSH when using Windows. There are two good ways to do this. First, use a tool like mobaXterm. Let's face it mobaXterm is pretty awesome and is an excellent way to get a bunch of your favorite Unix tools over to windows. But what if you're already invested in Putty (as so many of us are). Well aside from mobaXterm's new ability to import your putty sessions, there are other ways and I'm going to show you a three part process to get it running.

Step one, get your windows box an Xserver. There are options but I can personally recommend VcXsrv. It's been rock solid for me on Windows 7 and it doesn't seem to take up too many CPU cycles.

Step two, get your ssh sessions to setup your IP address as the place for your xserver. The easiest way to do this is to add a couple of commands to your .profile that will automatically tell your session where to send X output. Keep in mind that if you are not working on a box that's on your local network or you're not VPN'ed in somewhere you will probably have to setup port forwarding on your router. In this example you are the primary X display so you'll need to open 6000. But ports can be higher in unique circumstances. But barring network issues something like this:


meip=`echo $SSH_CLIENT | awk '{{print $1}}' `
export DISPLAY=`echo $meip:0`
or for HP-UX
meip=`who -u am i | awk '{{print $8}}'`
export DISPLAY=`echo $meip:0`

And your final step is to configure putty to allow X. The math department at the U of Minn has a good doc on it. But the basic idea is your going to go into Settings -> Connections -> X11 and check a box Labeled "Enable X11 forwarding".

And that's it. You should now be good to run your X server with no large issues.

MWguy