Ubuntu as Home Print Server

Filed Under Linux | Comments (1) | Page Tools

CUPS+SAMBA Setup

You can extend the above CUPS-only configuration to include printer sharing through Samba. This is a more advanced configuration and requires command-line based editing and operations. More information can be found in the Samba How-To Chapter 22 CUPS Printing Support. This is a very comprehensive and detailed description of the integration between Samba and CUPS.

To enable this you need to modify the /etc/samba/smb.conf file. There are two sets of settings you need to change, one in the [global] section and the other in the [printers] section. This assumes you have configured Samba already for file sharing on the network. There are some common settings, such as the security settings, that may affect the printer sharing.

#1 – In the [global] section, you need to tell Samba to use CUPS for printing by uncommenting the cups references. Here’s my Printing settings in the [global] section of the file.

########## Printing ##########

# If you want to automatically load your printer list rather
# than setting them up individually then you'll need this
   load printers = yes

# lpr(ng) printing. You may wish to override the location of the
# printcap file
;   printing = bsd
;   printcap name = /etc/printcap

# CUPS printing.  See also the cupsaddsmb(8) manpage in the
# cupsys-client package.
   printing = cups
   printcap name = cups

The print-related settings for Samba can be found listed in Table 2 of Chapter 10 “Printing” of the Using Samba book. You need:

  • load printers = yes so that Samba will load the list of defined printers and you don’t need to code a share for each one
  • printing = cups tells Samba to use CUPS for printing
  • printcap name = cups is ignored; there’s no need to specify a printing capacity file for cups

I have seen some documents that say you also need to set workgroup = {workgroup name} and security = user or security = share (and setup the appropriate users). I did define a user “david” and map it to samba. However, as far as I can tell, the printer connectivity is using the guest account.

#2 – In the [printers] section you need to define how the printers are defined to the outside world. You do not need explicit shares for each printer, the default one will do.

[printers]
   comment = All Printers
   browseable = yes
   path = /var/spool/samba
   printable = yes
   guest ok = yes
   read only = yes
   create mask = 0700
   use client driver = yes

The settings used are:

  • comment = All Printers is effectively a label for the section
  • browseable = yes means the printers can be browsed on the Windows machine; you don’t need to explicitly define it (e.g. you can browse under the server to list the printers, rather than having to know the printer name and entering \\{server}\{printer})
  • path = /var/spool/samba is the location of the spool file and doesn’t need to be changed
  • printable = yes tells samba that this is a printable share
  • guest ok = yes means the guest account can connect to the printer, i.e. any Windows account can use the printer, without specifying a password
  • read only = yes means that the share is read-only
  • create mask = 0700 is the file permissions mask and does not need to change
  • use client driver = yes means that if there is no driver for this printer in the Samba repository, allow the Windows print definition to use a local driver

Please follow the relevant links for more detailed explanation of the settings.

#3 – Once the settings have been changed, Samba must be restarted:

sudo /etc/init.d/samba restart
 * Stopping Samba deamons                                       [ OK ]
 * Starting Samba deamons                                       [ OK ]

You can ignore the [print$] share section for now as it defines the driver repository configuration.

Samba is now ready for a new printer definition on a Windows machine. The printer creation is similar to that shown in the previous section until the Specify a Printer page of the wizard, where you select Browse for a Printer. On the next page of the Wizard, the Browse for Printer page, expand the Linux server name and select the raw printer listed.

samba-1

Following this you will get two annoying, but not important messages:

  1. First there is a message indicating that you’re about to connect to a printer on the Linux machine and it will download the printer drivers which may be a security hazard. This means it’s about to get the printer drivers from the driver repository specified in the [print$] share section in smb.conf. There are no drivers there, so this is not a concern. message-1
  2. Next there is a message saying that no driver was found on the server (as I’ve just said) and if you click OK you will be able to go and load one from the Windows machine. This is what we want. message-2

When you click OK from the second message, you are then presented with the usual Windows dialog to go find the driver.

samba-2

You then create the printer and can test by printing a test page.

Loading Drivers into the Samba Driver Repository

I’ve not done this and it look quite complex. See:

This concludes this article.

Page Tools

  • RSS
  • Email this Post
  • Print This Post

No related posts.

Comments

One Response

  1. I am new to Linux and was struggling to understand the documentation and the multitude of advice on the Internet. Your article gave me the light and just enough knowledge to get my print server working.

    Thank you

    Comment by Pierre at January 26th, 2010 at 8:41 pm

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.