Printable Version of this PageHome PageRecent ChangesSearchSign In

Printing on the LAWN

This solution will let you print on the LAWN from a Mac OS X machine using the standard print dialog. The biggest catch is that you need to use the Apple PDF Services mechanism, so instead of selecting your printer in the print dialog, you select a PDF workflow option (where the "Save as PDF..." button normally is). There are a couple of other limitations, too, but they are fairly minor or easy to work around. There are other printing solutions, some of which may be easier, but they involve printing as root, which I don't like.

Here are the steps you need to perform:

I know it sounds like a lot, but I'll walk you through it below.

Create the PDF Services directory

Navigate from your home folder to the Library directory. If there is a folder named PDF Services, then open that folder. Otherwise, create a new folder and rename it to PDF Services.

Download the Print to <printer> scripts

Download the Print to <printer> files for any printers you wish to use and put them in the PDF Services folder you just created. These are the programs that will be used to send your printouts to the printer. We now need to make sure that the scripts are executable. Launch Terminal (you can find it in the /Applications/Utilities folder). At the command prompt, type:
    cd ~/Library/PDF\ Services
    chmod +x Print\ to\ *

Set environment variables

We need to set some environment variables so the Print to <printer> scripts will work. On a UNIX system, we'd just edit our shell's resource file, but on Mac OS X, that won't work for any of the applications that you run via the Finder (Safari, Mail, etc). But Mac OS X does provide a way to set environment variables for applications run through the Finder, so we'll use that. We first need to create the directory ~/.MacOSX (if it doesn't already exist). To do this, use the Terminal application. At the command prompt, type:
    mkdir ~/.MacOSX

Now we'll need to create a file, environment.plist, in that directory (if it doesn't already exist). If the file doesn't exist, you can download my environment.plist file and put it in the ~/.MacOSX folder. To open the ~/.MacOSX folder in the finder, press command-shift-G or select "Go to Folder..." from the Go menu. Type ~/.MacOSX and press return.

Configure SSH keys

We need to configure SSH to use public keys rather than your UNIX password so that the SSH Agent can provide access to the keys. If you do not already have an SSH key configured for your machine, you need to create one. If you already have one created and can log in to a CoC system using that key, skip forward to the next step.

From the Terminal, run the following command:
    ssh-keygen -t rsa

This command generates an RSA public/private key pair. When you are asked where to save the key, just press return to use the default. When you are prompted for a passphrase, choose a good passphrase for your key. This is the passphrase that the SSH Agent will use to unlock your SSH key. If you have no idea what I'm talking about, don't worry – just pick a good passphrase. You should see something similar to the following:

    Your identification has been saved in /Users/eaganj/.ssh/id_rsa.
    Your public key has been saved in /Users/eaganj/.ssh/

The first file is your private key. Don't give it out. The second file is your public key. That one you can give out freely, if you want to.

We now need to configure the CoC UNIX machines to accept your SSH key. You can do this on any CoC UNIX machine – they will all use your SSH key once you configure one to use it. I'll use helsinki, but you can use your favorite CoC UNIX machine here. In the Terminal, type (on one line – I've wrapped it here for readability):

    ssh "cat >> ~/.ssh/authorized_keys; 
    chmod og-r ~/.ssh/authorized_keys" < ~/.ssh/

Make sure you replace USERNAME with your Unix username (login) in the above line. If you are asked whether to accept the host key, answer yes. When asked for your passphrase, type in the passphrase you provided when you generated the key, above.

Install SSHAgent

The Print to <printer> scripts use SSH and scp to copy your print jobs to your CoC UNIX account and send the print jobs from there. In order to login to your CoC account, we need to set up an SSH agent to store your login credentials. We can configure the SSH agent to either ask you for your passphrase every time you print or to store that passphrase on your Mac OS X keychain. In either case, we need to install the SSH agent. The agent enables a GUI program to obtain your SSH passphrase. You can download the SSHAgent here. (If you are paranoid (like me), you can download the SSHAgent source code here. I leave building from source to you).

Put the SSH Agent anywhere you wish. I keep mine in ~/Applications. You may wish to run it at login. In Jaguar (Mac OS X 10.2), select the Login Items preference pane from the System Preferences. In Panther (Mac OS X 10.3), you use the Accounts preferences pane from System Preferences and select the Startup Items tab. Drag the icon for the SSH Agent to the applications list.

We now need to make sure that the SSH Agent can set itself to run as the passphrase agent for your SSH sessions. To do that, launch SSH Agent by double-clicking on it. Select the SSH Agent > Preferences... menu item. We need to make sure that the Add Default Identities item is checked. Also, make sure that the Make Agent Global box is checked (BUG alert: if this is your first time using SSH Agent and the Make Agent Global box is checked, you need to uncheck, then re-check the box to correctly enable this setting).

Now move to the Default Identities tab. Click the Add Identity... button. Select the private key that you created earlier (id_rsa).

Log out

We now need to log out and then log back in to make sure that any applications you start from the Finder will use the SSH Agent.

Print via PDF Services...

To print, we need to make sure that the print request gets passed on to the Print to <printer> scripts that we just created. When you bring up a print dialog, configure whatever options you wish as normal, but instead of hitting the Print button, use the PDF button on the bottom of the screen (the button has an icon of a PDF document on it and a small arrow). Just select the Print to <printer> script for the printer you wish to use.

Uploaded Image: printDialog.png


There are a few limitations to this configuration. When you print with this configuration, your print job is converted to a postscript file, which is then transfered to your CoC unix share and sent to the printer as if you were printing from one of the CoC-maintained Linux machines. Because of this process, some settings from the printer dialog (e.g. paper orientation, pages-per-sheet, etc.) will not work properly. For basic printing operations, however, this configuration should work.

It should also be noted that to print in duplex, you need to make sure you send the print job to the duplex version of the printer script. For example, to print duplex to Mom, you need to select the Print to Mom (Duplex) script.

Also, some applications disable PDF Services, which prevents this method from working. The only application I know of that does this is Adobe Reader, but Apple's Preview program handles PDFs quite nicely, so I usually use that.

Last modified 5 March 2007 at 8:00 pm by eaganj