OSX X11 Forwarding

I access var­i­ous Unix and Unix-like sys­tems all the time.  In most cases I don’t ever use any of the GUI tools or appli­ca­tions they may pro­vide.  I’ve been using Linux since before Slack­ware was even a dis­tri­b­u­tion, and Unix longer than that, so I gen­er­ally find GUIs get in my way more often than not.  That said, some­times a GUI tool is the best way to do something.

Some peo­ple like VNC, but I’ve always been an SSH man myself.  And, I’ve always used SSH X11 tun­nel­ing when I need it.  That means that on my Win­dows machine I have the Exceed suite installed, which includes a nice X11 instal­la­tion for Win­dows.  Every­where else, however–including on my Mac­book Pro–I’ve always just used the native X11 win­dows man­agers.  Until recently.

I hadn’t noticed that X11 tun­nel­ing wasn’t work­ing from my Mac until recently and found out that the X11 win­dow man­ager has been gone from Mac since Moun­tain Lion–which tells you how often I use GUI apps in this way.  It’s not a big deal to fix, but I fig­ured there are prob­a­bly some peo­ple out there who don’t know how to make it all work, so I’d type up this quick blurble.

Essen­tially, you just need to down­load XQuartz and install it.  XQuartz is the new ver­sion of what used to be the X11.app that came by default in OSX ver­sions prior to Moun­tain Lion.  Or, it’s the same project.  Or some­thing.  You can read the Apple blurb here.

If you don’t have X11 for­ward­ing turned on, just edit your /etc/sshd file and change the X11 For­ward­ing line to be like so:

/etc/sshd file





Be sure to restart any ssh ses­sions you have open, and then con­nect using the –X flag in ssh.  Some­thing like “ssh –X username@host.com” should work.  Read the man page on ssh if you have any ques­tions, but it’s pretty straight for­ward over­all.  Once logged into your remote machine you can ver­ify if things are work­ing by run­ning any kind of X11 app (xclock or xeyes are my usual test sub­jects).  If not, start by echo­ing your local dis­play vari­able (echo $DISPLAY) and see if you have any­thing there.  If it’s empty, then your local ssh client isn’t for­ward­ing the X11 infor­ma­tion 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, some­thing else will be bro­ken or changed.