<Span Class="caps">OSX</Span> <Span Class="caps">X11</Span> Forwarding

Read­ing Time: 2 min­utes

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

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 recent­ly.

I had­n’t noticed that X11 tun­nel­ing was­n’t work­ing from my Mac until recent­ly and found out that the X11 win­dow man­ag­er 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 blur­ble.

Essen­tial­ly, 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 pri­or 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 [email protected] ” should work.  Read the man page on ssh if you have any ques­tions, but it’s pret­ty straight for­ward over­all.  Once logged into your remote machine you can ver­i­fy if things are work­ing by run­ning any kind of X11 app (xclock or xeyes are my usu­al 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 emp­ty, 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 infor­ma­tion).

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.