4. Sharing Printers With Windows PCs

4.1. Sharing Basics

Figure 3. Printer Sharing

Samba uses nmbd and smbd daemons to share files and printers with Windows PCs. nmbd acts as a Windows naming service, broadcasting your computer's name to Windows PCs on the LAN. smbd accepts file and printer requests from Windows PCs Figure 3.

You will need to download and install Windows printer drivers for each Linux printer you are sharing. Windows printer drivers can be found by searching the web site of your printer manufacturer.

4.2. Samba Configuration

If you are allowing anonymous access to your printer you will need to create a user account for remote print jobs:
/usr/sbin/adduser --system --disabled-password smbprint

This command adds a user called "smbprint" to your system. Make sure there is enough disk space in /home/smbprint, the "smbprint" user's home directory, to spool files. Check that the "smbprint" user does not have permission on your system to read or modify sensitive files and directories. If you have configured CUPS to restrict printing to certain users on your system, you must allow the "smbprint" user to access printers you want to share.

The Samba configuration file is /etc/samba/smb.conf. The following is an example configuration file set up to use CUPS with the "smbprint" user:
[global]
  printcap name = cups  
  printing = cups   
  security = share   
[printers]   
  browseable = yes   
  printable = yes   
  public = yes   
  create mode = 0700   
  guest only = yes   
  use client driver = yes
  guest account = smbprint   
  path = /home/smbprint   

Please note that this configuration will allow printing by anyone that can make a network connection to your computer and is not recommended for computers on untrusted networks, such as computers with direct Internet connections. If you need to implement access control, set security = user or security = domain and read the Samba man pages for further information.

Once you have added the above settings to your Samba configuration file you must restart Samba with the command:
/etc/init.d/samba restart

4.3. CUPS Configuration

Windows printer drivers format their output for the printer before sending it across the network. You must configure CUPS to accept the pre-formatted output by uncommenting the following line from /etc/cups/mime.convs:
application/octet-stream   application/vnd.cups-raw   0   -

Also uncomment the following line from /etc/cups/mime.types:
application/octet-stream

Now CUPS must be told to allow connections from other machines on the network. Add these lines to /etc/cups/cupsd.conf:
<Location /printers>
 AuthType None
 Order Deny,Allow
 Deny From None
 Allow From All
</Location>
As in the Samba configuration, this configuration allows any computer to connect to your printers and is not recommended for computers on untrusted networks. For information about tightening access control to your printers, see the cupsd.conf man page and the CUPS documentation.

Finally, restart cups with the following command:
/etc/init.d/cupsys restart

Your Linux printers should now be shared to Windows PCs on the LAN. Follow the usual steps for adding a network printer to your Windows PCs, and remember to print a test page.