Network printing is a leading cause of high blood pressure and premature hair loss in our long-suffering network administrator demographic. Fortunately, the FOSS world, as usual, does its best to mitigate our suffering. Today you shall learn how to use CUPS and Samba together to set up automagic client printer installations. That’s right, my hardworking friends, none of this dashing about to individual workstations burdened with driver disks and Windows CDs. The goal here is to never leave your snug underground lair.
Please note that today’s topic is only about printers. I know you’re dying to figure out how to share your multi-function devices, so that all your LAN hosts can scan and fax. We’ll get to this in a future article, especially how to share scanners, because that is something you can do in Linux that you can’t do in Windows.
The Easy Way: Buy The Right Printer
In my ideal environment, all printers would have native networking and administration utilities. Samsung and HP both have a lot of printers with Linux, Mac OS X, Windows, and networking support. You can get a nice network-ready (wired and wireless) Samsung color laser for under $500, which is a lot more fun and less work than running a separate printer server.
Since we don’t all have the option to purchase wonderful new printers, the next best thing is a robust Linux printer server starring CUPS and Samba. The CUPS/Samba printer we’re building today will not require users to authenticate to install and use printers, so it’s not for admins who need everything locked down. This setup is good for home users, businesses that don’t need a lock on everything, and those unfortunate network admins who still have Windows 9x machines under their care.
- Name resolution working reliably
- An already-configured and working CUPS server with printers configured
- The cups-devel package installed, also called libcups2-devel and libcupsys2-dev
- Samba server
- CUPS Windows drivers
- Adobe or Microsoft Postscript drivers
The commands and examples are all from a Debian system, so you may need to
adjust filenames for different systems.
If you don’t have a Samba server already running on your network, here is a complete example configuration. All of your Windows hosts must belong to the workgroup named in smb.conf. Linux and Mac OS X don’t care about workgroups, so don’t worry about them.
First create these two directories:
# mkdir -m 777 /sharedstuff
# mkdir -m 777 /var/spool/samba
Then create this smb.conf, using your own LAN address and workgroup name:
'global' workgroup = samba2 netbios name = xena server string = lan file and printer server hosts allow = 192.168.1. security = user load printers = yes printing = cups printcap name = cups'share1' path = /sharedstuff comment = files for everyone read only = no browseable = yes guest ok = yes'printers' comment = All Printers path = /var/spool/samba browseable = yes printable = yes writable = no guest ok = yes'print$' comment = Printer Drivers path = /usr/share/cups/drivers browseable = yes guest ok = no read only = yes write list = root
Run the testparm command to check your syntax. If you get a “WARNING: passdb expand explicit = yes is deprecated” error, ignore it, it’s a leftover meaningless bit of cruft. Restart Samba:
# /etc/init.d/samba restart
Now you should have a “share1” folder in Network Neighborhood and your other Samba browsers. Use this to copy the driver files between your machines, which we’ll get to in a moment.
This is a nice simple CUPS configuration for sharing printers. Make sure you have the last four lines- those are necessary for sharing Windows printers:
Deny From All
Allow From 192.168.1.*
Allow From 127.0.0.1
Allow From 127.0.0.1
Deny From All
application/octet-stream application/vnd.cups-raw 0 -
CUPS Windows Drivers
Download and unpack the CUPS Windows drivers, currently cups-windows-6.0-source.tar.gz. Enter the source directory and run this command:
# make install
Creating directory /usr/share/cups/drivers…
Now you need either the Postscript drivers copied from a Windows PC, or get the Adobe drivers, winsteng.exe. They’re all the same; get the Adobe drivers if you can’t find them on your Windows PC.
To use the Adobe drivers, download and install them on a Windows system. You don’t need a printer, you just want to extract the files. On Windows 2000/XP, look for the windowssystem32spooldriversw32x86 directory. On Windows 9x/ME look for the WIN40 directory. Copy the contents of these directories into /usr/share/cups/drivers directory on the Samba/CUPS server. This is how it looks for Windows 2000/XP:
cups6.ini cupsps6.dll cupsui6.dll ps5ui.dll pscript5.dll pscript.hlp pscript.ntf
Add these for Windows 9x/ME:
adfonts.mfm adobeps4.drv adobeps4.hlp iconlib.dll psmon.dll
Be to sure to convert all filenames to lowercase. If you don’t cupsaddsmb won’t work.
Export CUPS Drivers to Samba
Now create a Samba user. This must correspond to a Linux system user. The easy way is to use root:
# smbpasswd -a root
New SMB password:
Retype new SMB password:
Now export the CUPS drivers to Samba with cupsaddsmb. If you have more than one Samba server on your network, disconnect from the network first or cupsaddsmb will go nuts trying to install all the printers, which won’t work:
# ifdown eth0
To export the drivers, use the command:
# cupsaddsmb -H localhost -U root -a -v
You can get an idea of just how much output the command produces, and what you should expect to see, by looking at Figure 1.
Important smb.conf Tweak
Go back to your smb.conf and make a small but very important change. Change security = user to security = share. If you don’t, you’ll have to set up Samba users and passwords for all of your users.
Restart CUPS and Samba, and rejoin the network:
# /etc/init.d/samba restart
# /etc/init.d/cupsys restart
# ifup eth0
Automagic Windows Installation
Give Samba a minute or two to broadcast itself to your LAN. Then go to any Windows PC on your LAN, run the Add Printer Wizard, and voila! Automatic printer installation from the Samba server.
If you get a message like “the printer server does not have the correct printer driver installed” you have a couple of options. First, test the offending .ppd file with the cupstestppd command. PPD files are plain text files, so if you can find an error you can fix it.
Another option is to search for a .ppd file that Windows will accept. You might find this on another Windows PC, on the same Adobe page where you downloaded the Postscript drivers, or on linuxprinting.org.
Finally, the worst-case scenario is you have to hunt down a driver CD, and don’t forget your Windows CD, and install the drivers locally. True, this means leaving the lair, but with a bit of luck it won’t happen often.
The Official Samba-3 HOWTO and Reference Guide