Community Chair of STEM
Department of Computer Science
University of Nebraska at Omaha
LAWN + CoC Linux PrintingAfter recently switching to Ubuntu Linux on my laptop (from Windows) I was suprised to learn that our College of Computing IT support staff had no solution for printing to college printers from an "outlan" machine that was running Linux (or Macs for that matter). After futzing with CUPS and some shell scripts, I have come up with the following instructions:
Configure SSH identity keysSee http://home.cc.gatech.edu/eaganj/18#sshkeys at James Eagan's page for details on this step.
Create printer scriptsFor each printer you want, create a script called "/usr/local/bin/lpXXX" where XXX is replaced with the printer name. This script will need to ssh to a CoC server and invoke the lpr command with the appropriate argument. For example, below is my lpdad script:
/usr/bin/ssh -q helsinki.cc.gatech.edu lpr -Pdad
If you want to also have the duplex version of the printer, be sure to create a lpXXX-duplex script too! And don't forget to make these scripts executable (chmod +x lpXXX).
Create cups backend scriptsIn the directory /usr/lib/cups/backend create a script named gtXXX (or something else that's intuitive) for each printer you're installing. Below are the contents of my gtdad script:
#!/bin/sh cat $6 |sudo -u dorn /usr/local/bin/lpdad
Change the argument "dorn" to match your local Linux/Mac username. Again, make sure these scripts are executable.
Restart your cupsys process. For me using Ubuntu that's "/etc/init.d/cupsys restart"
Note, there is likely a way around making two scripts, but security considerations in the next step led me to this solution.
Update sudoersWe have to allow the cupsys user assume our own credentials for doing the ssh operation (so that our rsh keys get picked up). At the command prompt as root type "visudo" and add a line like what is shown below:
cupsys ALL=(dorn) NOPASSWD: /usr/local/bin/lpdad
Again, you'll need one line for each printer script you created. Also, if your cupsys user operates on anything other than a localhost, you'll need to massage the ALL to limit access accordingly.
Install you printers with cupsProceed through the typical add printer dialog for your OS to create a printer with the appropriate driver. If you use the web-based interface, select "Backend Error Handler" for the DEVICE in the second step (you may need to install the error handler for cups to show it). When prompted for the device URI, enter the corresponding backend script that you created followed by "://junk". For example, for dad:
Select your make, model, and driver as normal. You'll also want to go set the defaults in the printer setup dialog (e.g., default paper size and whether to do two-sided printing or not).
If you have problems using the cups interface, you can always edit the printers.conf file by hand and specify the drivers manually. I've included my files for dad and dad-duplex below. The PPD files go in /etc/cups/ppd/ and printers.conf belongs in /etc/cups
Huzzah!You should now be able to print to this printer.
Last modified 24 August 2007 at 12:18 pm by dorn