Howto: Printer sharing with CUPS

Share your own howto's etc. Not for support questions!

Howto: Printer sharing with CUPS

Postby Lavene » 2006-11-30 11:47

This HOWTO describe how I set up printer sharing between machines running Debian GNU/ Linux 4.0 aka "Etch" using the Common Unix Printer System, known as "CUPS". The setup in this HOWTO is comprised by one headless server with no desktop software and a number of KDE workstations. CUPS is a complex piece of software so the method described herein is just one I found to work. There are probably several other ways to achieve the same result. This HOWTO require editing of vital system files, make sure to back up the original before making any changes.
This HOWTO is licensed under the terms of the GNU Free Documentation License. It has been written in the hope that it will be useful to the community but it comes with no warranty; use it at your own risk.

This HOWTO assumes:
- That you have the proper drivers/ software for your printer installed on your server. A very good site for finding drivers or Linux compatible printers is http://www.linuxprinting.org/ The Gutenprint, Gimp-print, Foomatic etc is available through apt-get but be aware that they might be lagging a bit behind so if you got a brand new model you printer might not be supported. For clarity I will use my own printer, a Epson Stylus C48, and the Gutenprint driver as an example. Also I will use as sample IP addresses 192.168.0.100 for the server and 192.168.0.150 for administration workstation.

- That you have a working network with SSH

- Some basic knowledge about TCP/IP networking

Setting up the printer server:
The first thing you need to do is to install CUPS:
Code: Select all
apt-get install cupsys cupsys-driver-gutenprint foomatic-db-gutenprint foomatic-filters fontconfig libtiff4 libfreetype6

Note: You might need various other packages and libraries depending on your printing needs.

If your network use DHCP it's a good idea to set up your server to use static IP. As root, open the file /etc/network/interfaces in a text editor, locate the "# The primary network interface" and change it to:

Code: Select all
# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.0.100
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255
        gateway 192.168.0.254

Note: Change the values to suit your network setup. You might also want to do the same on the administrator machine.
Save the new configuration and restart the network:
Code: Select all
/etc/init.d/networking restart


Configure CUPS
Now we need to configure CUPS. In an editor, as root, open /etc/cups/cupsd.conf

First, check the encryption setting and change it to (if it's not there you should add it):
Code: Select all
# Encryption
Encryption IfRequested


Then we need to tell it to listen for the server it self:
Code: Select all
# Only listen for connections from the local machine.
Listen localhost:631
Listen 192.168.0.100
Listen /var/run/cups/cups.sock

Note: This seem unlogical and I have no explanation for it, but it simply did not work for me when using just 'localhost'.

We need it to be visible to the entire network:
Code: Select all
# Show shared printers on the local network.
Browsing On
BrowseOrder allow,deny
BrowseAllow @LOCAL


We also have to tell it what machines that may access the server:
Code: Select all
# Restrict access to the server...
<Location />
  Order allow,deny
  Allow localhost
  Allow 192.168.0.*
</Location>

Here you can specify each IP or, as in my example, use "*" as a wildcard.

We don't want every user to be able to use the admin web interface so we tell the server what machines are allowed:
Code: Select all
# Restrict access to the admin pages...
<Location /admin>
  Encryption IfRequested
  Order allow,deny
  Allow localhost
  Allow 192.168.0.150
</Location>


And the same for the configuration files:
Code: Select all
<Location /admin/conf>
  AuthType Basic
  Require user @SYSTEM
  Order allow,deny
  Allow localhost
  Allow 192.168.0.150
</Location>


The rest of the configuration I left as default:
Code: Select all
# Set the default printer/job policies...
<Policy default>
  # Job-related operations must be done by the owner or an administrator...
  <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job CUPS-Move-Job>
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>

  # All administration operations require an administrator to authenticate...
  <Limit Pause-Printer Resume-Printer Set-Printer-Attributes Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After CUPS-Add-Printer CUPS-Delete-Printer CUPS-Add-Class CUPS-Delete-Class CUPS-Accept-Jobs CUPS-Reject-Jobs CUPS-Set-Default>
    AuthType Basic
    Require user @SYSTEM
    Order deny,allow
  </Limit>

  # Only the owner or an administrator can cancel or authenticate a job...
  <Limit Cancel-Job CUPS-Authenticate-Job>
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>

  <Limit All>
    Order deny,allow
  </Limit>
</Policy>

#
#

To apply the new configuration we need to save the file and then restart CUPS:
Code: Select all
/etc/init.d/cupsys restart

You should now be able to connect to the CUPS web interface from the administrator workstation (IP 192.168.0.150 in my example) by pointing your web browser at http://192.168.0.100:631/
Then, if you got the correct drivers installed and your printer is connected to the server, it's just a matter of adding your printer under the "Administration" tab. The web interface is fairly self explanatory with good help sections, and also the setup will vary depending on the printer etc so I will not go into details about it here.
Finish the setup and verify that it works by printing the CUPS test page.

Setting up the CUPS clients:
The CUPS clients are easy to set up and the config is identical on all machines.
First install the CUPS client packages:
Code: Select all
# apt-get install cupsys cupsys-client


Then create, as root, the file /etc/cups/client.conf
This file is really simple and contains only two lines: the server IP and the encryption requirement:

Code: Select all
# Servername
ServerName 192.168.0.100

# Encryption
Encryption IfRequested

Save the file, then restart the client:
Code: Select all
/etc/init.d/cupsys restart

The last thing we need to do is to set our printer as the standard printer in KDE.:
    Open Controllcenter --> Peripherals --> Printers
    Click "Administrator mode"
    Select "CUPS (Common UNIX Printing System)"

That's it! KDE will route all printing through your freshly set up CUPS client.

A personal note: KDE has a feature which should be able to set up both the CUPS server and client but I could not get this to work. The idea is that KDE can create the config files, but it looked like the KDE setup program was way behind the CUPS package because it kept complaining about unknown setup options and I always ended up with weird configuration files. By creating the config files manually you bypass that problem entirely.

I have also received the following tip: If you experience problems connecting to your server try and add "Allow <server IP>" in all instances where you have "Allow localhost"

Tina
Lavene
Site admin
 
Posts: 5099
Joined: 2006-01-04 04:26
Location: Oslo, Norway

One follow up to the great how to on CUPS

Postby etchuser » 2007-01-29 23:39

I followed this write up to reinstall etch as a server and I have a USB printer connected to the Etch box and I could not get the printer to "install" using CUPS till I found this document.

I did run into one small snag at the end. When I entered my servers ip directly into a browser; 192.168.2.7:631 to administer the server and saw that USB printer was now shown I encountered an error when I tried to add the printer.

The error was "426 Upgrade Required" and I had to use https://192.168.2.7/admin to access the page.

I found googling that if I edited this line in cupsd.conf
# Default authentication type, when authentication is required...
DefaultEncryption IfRequested

And modified to use DefaultEncryption IfRequested I could add the USB printer and the CUPS required a login name and password and I was in business.
etchuser
 
Posts: 1
Joined: 2007-01-29 23:31

Postby patrick295767 » 2007-02-02 17:20

That's a great HOWTO !!

btw, would you have time to make a similar as good howto for Sharing this printer via SAMBA for windows machines too ?

thank you very much !!
Please even during the wind, may Debian remain as trustable, highly-stable, secured, lightweight, and bug-free as always !
http://www.babytux.org/gallery/images/couchtux.jpeg
website
User avatar
patrick295767
 
Posts: 246
Joined: 2006-12-23 22:55

Postby Lavene » 2007-02-03 05:36

patrick295767 wrote:That's a great HOWTO !!

btw, would you have time to make a similar as good howto for Sharing this printer via SAMBA for windows machines too ?

thank you very much !!


Well, I probably have the time. What I don't have is Windows (that's right, I completly dumped Windows a long time ago) so consequently I don't use Samba.

Tina
Lavene
Site admin
 
Posts: 5099
Joined: 2006-01-04 04:26
Location: Oslo, Norway

Postby begatelles » 2007-02-03 16:54

Another Great HowTo, and very straight forward. Thanks so much.
begatelles
 
Posts: 51
Joined: 2007-01-03 12:24

Thanks a Million!

Postby dcparris » 2007-02-16 11:38

I did it! I actually successfully configured CUPS to print over the LAN! Oh, I've always been able to configure a local printer, but never got anything working over the LAN. I had read another tutorial that helped me fine with the server config, but I needed the client-side config as well. This howto did it.

I had OpenOffice.org open, and had to restart it to get it to recognize the CUPS server. So everything worked out.
D.C. Parris
Editor, Pastor, and crazy as I don't know what
LXer - Linux News
dcparris
 
Posts: 1
Joined: 2007-02-16 10:45
Location: Charlotte, NC

Postby rodericj » 2007-02-17 21:24

I am unable to connect to the web admin page.

My error log states something like this...

Code: Select all
I [17/Feb/2007:16:22:30 -0500] Full reload complete.
D [17/Feb/2007:16:22:30 -0500] StartListening: NumListeners=3
D [17/Feb/2007:16:22:30 -0500] StartListening: address=7f000001 port=631
D [17/Feb/2007:16:22:30 -0500] StartListening: address=c0a80102 port=631
D [17/Feb/2007:16:22:30 -0500] StartListening: address=00000000 port=631
E [17/Feb/2007:16:22:30 -0500] StartListening: Unable to bind socket for address 00000000:631 - Address already in use.



Any ideas on that?
rodericj
 
Posts: 11
Joined: 2006-06-22 14:37

Postby sinaen » 2007-03-18 22:23

wow! its a lovely simple howto.. :)

but i am still stuck at how to find the
Device URI: for my printer i'ts pretty simple maybe but i dont understand how to get where to point my local printer to my cupsserver.
sinaen
 
Posts: 1
Joined: 2007-03-18 22:20
Location: sweden jokkmokk

Postby tukuyomi » 2007-03-19 06:09

sinaen: From the cups client, go to http://cupsserverip:631/printers/ and rightclick->copy link location on the printer you want, then paste it on the URI textbox :)
tukuyomi
 
Posts: 121
Joined: 2006-12-05 19:53

Postby ingo » 2007-07-12 18:50

can anybody make this work with a mac, too?
User avatar
ingo
 
Posts: 188
Joined: 2007-04-15 14:15
Location: capital of beer

Re: Howto: Printer sharing with CUPS

Postby dbbolton » 2010-01-25 08:30

This thread is quite dated. I stumbled on it through Google. I think what I had to do (or did) was run these commands:

server
Code: Select all
cupsctl --share-printers


client
Code: Select all
cupsctl BrowsePoll=192.168.1.22:631
cupsctl 'BrowseRelay="127.0.0.1 @LOCAL"'


Also, I used two wildcards for each section of the config on the server
Code: Select all
192.168.0.*
192.168.1.*
User avatar
dbbolton
 
Posts: 1185
Joined: 2007-06-20 08:17
Location: WV

Re: Howto: Printer sharing with CUPS

Postby KeithW » 2010-02-06 01:50

Brilliant HowTo, very helpful, thanks very much.

Using this and http://www.linuxforums.org/articles/how ... ps_52.html helped me to set up a mixed Linux and Windows home network.
KeithW
 
Posts: 1
Joined: 2010-02-06 01:47


Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 4 guests