X11 Forwarding and SSH on OS X

Posted by Andy Atkinson on November 7, 2005

This article is a quick and dirty guide detailing my experience getting X11 Forwarding to work on OS X. You don't need to know all of the details of the X Window System or of the XFree86 Project to get this working, I found I just needed to know which ssh flags to use with the computer I was connecting to. One of the really useful things about my new iBook is having a system running ssh and capable of X11 Forwarding out of the box. This allows me to easily connect to machines at school for programming and other IT homework. Read on for details about how to get this working or add comments on your experience with OS X and X11.

I'm running OS X 10.4, so I needed to install X11 from my OS X install CD 1. This is not installed by default.

Install X11 from OS X CD

Once I installed X11, I expected to be able to open a Terminal window, ssh into a computer, and open a text editor like emacs in a background process. This didn't work. Here is a quote from Apple's Developer page on X11:

For security reasons, Mac OS X does not enable X11 forwarding by default. In order for clients to receive X11 forwarding, the system administrator must explicitly enable it on the Mac OS X system.

So far I haven't done this because I was able to connect to machines at the University of Minnesota without editing any config files. By typing man ssh you can view all of the different flags you can use with ssh. To connect to machines at the Univeristy, I needed to add the -Y flag.

I was able to launch X Windows applications with a X11 Terminal only, and not with the built-in OS X Terminal.

Use a X11 Terminal to enable X11 Forwarding

I've intentionally blurred machine names in the screenshots, but I've included the specific string I used to connect to machines at the University below. Note that the "l" is a letter and not the number "1."

$ ssh -Y machine_name -l username

Using ssh with X11 Forwarding

Now that I was logged-in to a Linux machine, I was able to launch X applications as background processes and maintain one ssh shell into the remote system. In the screenshot below I am launching the emacs text editor.

Using ssh with X11 Forwarding and emacs

Summary

X11 Forwarding is certainly possible on other operating systems like Windows and Linux, but I've never used anything that integrated as well as the implementation on OS X. Please feel free to add additional comments on X11 Forwarding or XFree86 and OS X in the comments. Here is an article on X11 and OS X, and this page contains a technical Q&A about more on X11 Forwarding.

About the author(s)

Andy started Pain in the Tech in 2005 as a way to share tips and tutorials with friends and family, and evangelize great products and services. By 2008, Pain in the Tech had 7 contributors, thousands of daily page views. Site ownership was transitioned to Matt Thommes in 2008.

Comments