Dedicated to my late brave, beautiful and silly mummy, Debra Ross. I love you mumster.

Skip navigation

Tunneling X11 through SSH on Mac OS X

As I increasingly use and rely upon Unix-like operating systems such as FreeBSD (and GNU/Linux) on desktops, I tend to forget at times that I’m using a sophisticated server installed locally to generate my graphical environments, namely X11. And just as with any server I can call it up from another machine and use its services.

X11.app X11 was built specifically to serve graphical applications over networks, and can still be used in this way by employing SSH on the client, and installing the desired applications on the server. My primary desktop is a DIY running FreeBSD 7.0 (more on my debacle with Debian GNU/Linux in a later post!), and my primary mobile machine is an original generation MacBook Pro.

USELESS ASIDE: Given the fact it’s about time for my half-yearly move back to Adelaide, Australia I’ve been contemplating how best to access my desktop machines here in Singapore using my MacBook Pro which I’ll be taking with me. These are the things that keep my up at night.

To access desktop applications on a remote Unix-like machine on your Mac, fire up your Terminal and use the regular SSH command, but with the -X flag:

% ssh -X [USERNAME]@[HOST MACHINE]
% Password: [PASSWORD]

Provided you have installed X11.app from either your Tiger or Leopard install DVD; or better yet downloaded the latest community build of Xquartz from MacOSForge; you should now be able to enter in the name of a graphical application and have it appear!

Tunneled FreeBSD X11 apps on Mac OS X
Tunneled FreeBSD X11 apps running on Mac OS X through SSH

For example, I entered % xfce4-panel and used that to launch some of my favourite apps, as you can see above. Over my local home gigabit ethernet connection and even at Starbucks on the free Singapore public WiFi networks the applications felt like they were running on my local machine.

You may recognise the Xfce panel from my previous post on Xfce and Openbox. There’s a reason for that; I’m using the panel remotely from the same machine. Ain’t [computer] science wonderful?

Plus then you can do things like run local Mac applications and the remote X11 applications on the same screen:

Tunneled FreeBSD X11 apps on Mac OS X
Xfce’s Thunar file manager compared to Leopard’s Finder

Leopard’s X11 issues resolved

Apple’s Leopard release of Mac OS X has been great in the user interface department, but their bundled X11 implementation is seriously broken which is a crying shame given it worked so well in Tiger. You can read my rambles about fun with X11 and some applications that didn’t work on it on my Software Compatibility with Leopard post.

Fortunately the X.org folks and Apple have stepped in and provided updated (albeit unofficial… what does that mean exactly?) XQuartz software which you can install from the command line.

bunzip2 Xquartz-<version>.bz2
sudo install -b Xquartz-<version> /usr/X11/bin/Xquartz

I’m running the latest downloaded version and it seems to have solved most of my Leopard X11 problems including having several X11 icons appearing in the dock, the slow tool movements in The Gimp, Inkscape refusing to boot, weird GTK theme failures and so forth.

Inkscape and The Gimp with the patched version of X11 on Leopard

What I want to know is why Apple didn’t choose to bundle and distribute this lifesaving X11 update using their Software Update mechanism or with the 10.5.1 update. I can only theorise that because it’s targeted mostly at power users who probably already run MacPorts or similar utilities that this was more appropriate, or maybe it has something to do with the fact that this is an “unofficial” release or beta.

As far as I’m concerned the X11 that ships by default with Leopard on disc is seriously broken, and this patch solves the problems. I can’t help but wonder though how many people who don’t know much about X11 have been put off Leopard because some of their apps are broken.

You can keep up to date with X11 on Leopard by keeping up to date with the XQuartz on Mac OS Forge website.