By July 26, 2011 0 Comments Read More →

Printing on W&I from Mac OS X Lion

This post has 537 words. Reading it will take approximately 3 minutes.

GD Star Rating
loading...

The Windows/Samba setup from BCF does not work well with the printing service in OS X Lion.  You can print via the command line using

cat <path to pdf file> | ssh <username>@ngrid04.win.tue.nl “cat | lpr -Pxerox7n1”

where I use ngrid04 as a random Linux machine I know I have access to and which I know can print using lpr.  I print to the printer xerox7n1.

This is a bit tedious, so I also made a quick and dirty automator action for this.  It is just a Automator workflow, which does the above.  In order to make this work, we also need ssh to play nice in scripts, which is why we need a quick shell-script, ssh-askpass (which I got from here) to handle that.

Installation

To install my hack, download this zip-file and unpack it somewhere.

Then double click on Print on ngrid.workflow

and select to open it in Automator

First, select Duplicate from the File menu.

Now, make sure you are working on the copy

and change the user name from mwesterg to your Linux username.  Optionally, also change the host from ngrid04 and the printer from xerox7n1 (keep the uppercase P, though).

Select to Save the document

and then supply a name that is meaningful to you

You also need to install ssh-askpass.  This is easiest done using the Terminal.app; open Terminal.app and type

sudo mv ~/Downloads/printer-hack/ssh-askpass /usr/libexec

You will be asked for your password; simply supply it and you should be good.

You can now print by selecting Print to ngrid in the drop-down doohickey at the bottom of print dialogs:

The first time, you may be asked whether you want to connect to ngrid04; if so, just type yes:

You will not be asked again.

You will also be asked for your Linux password; simply enter it

You may be asked for your password multiple times.

Avoiding Having to Enter a Password

The idea is to generate an ssh certificate and use that for login.  In Terminal.app, type

ssh-keygen -t dsa

The default location is fine.  You should enter a password.  The password should integrate with the OS X keychain, so you need to enter it once, and then it will be unlocked automatically if you select to add it to your keychain.  Or be lazy, and enter an empty password.

Finally, you need to install your certificate.  If you have never done this before, type the following command (on a single line) in the Terminal.app:

cat ~/.ssh/id_dsa.pub | ssh <username>@ngrid04.win.tue.nl “mkdir .ssh; chmod og-rwx .ssh; cat >> .ssh/authorized_keys2”

and remember to replace <username> by your Linux username.  You will be asked for your password.  Try executing the command again; you should no longer get a password prompt, but you do get an error “mkdir: cannot create directory `.ssh’: File exists”, but just ignore that.  You should now be able to print as before as long as you select the action from the dropdown.

Printing on W&I from Mac OS X Lion, 3.7 out of 5 based on 3 ratings
Posted in: Uncategorized

Post a Comment