OSX X11 Forwarding

I access various Unix and Unix-like systems all the time.  In most cases I don’t ever use any of the GUI tools or applications they may provide.  I’ve been using Linux since before Slackware was even a distribution, and Unix longer than that, so I generally find GUIs get in my way more often than not.  That said, sometimes a GUI tool is the best way to do something.

Some people like VNC, but I’ve always been an SSH man myself.  And, I’ve always used SSH X11 tunneling when I need it.  That means that on my Windows machine I have the Exceed suite installed, which includes a nice X11 installation for Windows.  Everywhere else, however–including on my Macbook Pro–I’ve always just used the native X11 windows managers.  Until recently.

I hadn’t noticed that X11 tunneling wasn’t working from my Mac until recently and found out that the X11 window manager has been gone from Mac since Mountain Lion–which tells you how often I use GUI apps in this way.  It’s not a big deal to fix, but I figured there are probably some people out there who don’t know how to make it all work, so I’d type up this quick blurble.

Essentially, you just need to download XQuartz and install it.  XQuartz is the new version of what used to be the X11.app that came by default in OSX versions prior to Mountain Lion.  Or, it’s the same project.  Or something.  You can read the Apple blurb here.

If you don’t have X11 forwarding turned on, just edit your /etc/sshd file and change the X11 Forwarding line to be like so:

/etc/sshd file





Be sure to restart any ssh sessions you have open, and then connect using the -X flag in ssh.  Something like “ssh -X [email protected] should work.  Read the man page on ssh if you have any questions, but it’s pretty straight forward overall.  Once logged into your remote machine you can verify if things are working by running any kind of X11 app (xclock or xeyes are my usual test subjects).  If not, start by echoing your local display variable (echo $DISPLAY) and see if you have anything there.  If it’s empty, then your local ssh client isn’t forwarding the X11 information and you might try using -vvv when you log in (lot’s of information).

Like I said, easy-peasy.  Now I can go back to not using any GUI apps for a few more years when, I’m sure, something else will be broken or changed.