Difference between revisions of "CUPS/Printer sharing"

From ArchWiki
Jump to: navigation, search
m (Removed newline)
(Remote administration: Add accuracy template for certificate generation not working)
 
(65 intermediate revisions by 15 users not shown)
Line 1: Line 1:
 
[[Category:Printers]]
 
[[Category:Printers]]
[[ru:CUPS printer sharing]]
+
[[ja:CUPS プリンター共有]]
{{Article summary start|Summary}}
+
[[ru:CUPS/Printer sharing]]
{{Article summary text|Setting up printer sharing using CUPS}}
+
[[zh-cn:CUPS/Printer sharing]]
{{Article summary heading|Related}}
+
{{Related articles start}}
{{Article summary wiki|Samba}}
+
{{Related|Samba}}
{{Article summary wiki|CUPS}}
+
{{Related|CUPS}}
{{Article summary end}}
+
{{Related articles end}}
  
[[CUPS]] provides capabilities to set up printer sharing between different systems. Below you'll find instructions for common scenarios.
+
This article contains instruction on sharing printers between systems, be it between two GNU/Linux systems or between a GNU/Linux system and Microsoft Windows.  
  
 
==Between GNU/Linux systems==
 
==Between GNU/Linux systems==
Once CUPS has been setup on the GNU/Linux print server, the recommended method of sharing the printer with another GNU/Linux system is through the relatively easy to use web interface, yet manual configuration is also a way.
 
  
You will need avahi-daemon running, before you restart cupsd.
+
The server can be configured using either the web interface or by manually editing {{ic|/etc/cups/cupsd.conf}}.
 +
To configure the client, see [[CUPS#Remote CUPS servers]].
  
 
===Using the web interface===
 
===Using the web interface===
  
Access http://localhost:631 with a browser and the CUPS administration home page will be displayed.  
+
Open up the web interface to the server, select the ''Administration'' tab, look under the ''Server'' heading, and enable the "Share printers connected to this system" option. Save your change by clicking on the ''Change Settings'' button. The server will automatically restart.
  
Click on the ''Administration'' tab near the top, select the add printer option and it should automatically detect the connected printer. If not, try turning off the printer and then back on before another attempt.
+
For more complex configurations, you can directly edit the {{ic|/etc/cups/cupsd.conf}} file by selecting ''Edit Configuration File''. See [[#Manual setup]] for more information.
 
+
Once the printer has been set up, look under the ''Server'' heading and click the checkbox for "Share printers connected to this system". Now, conclude by clicking ''change settings'' and the server will automatically restart.
+
 
+
Selecting "Edit Configuration File" allows making direct edits to the {{ic|cups.conf}} file. This is useful for allowing server access only to certain users or IP addresses, as the example shown below.
+
  
 
===Manual setup===
 
===Manual setup===
  
On the server computer (the one directly connected to the printer) simply open up {{ic|/etc/cups/cupsd.conf}} and allow access to the server by modifying the location lines. For instance:
+
On the server computer (the one directly connected to the printer), allow access to the server by modifying the location directive. For instance:
<Location />
+
{{hc|/etc/cups/cupsd.conf|
 +
<Location />
 
     Order allow,deny
 
     Order allow,deny
 
     Allow localhost
 
     Allow localhost
 
     Allow 192.168.0.*
 
     Allow 192.168.0.*
</Location>
+
</Location>
 +
...
 +
}}
  
Also make sure the server is listening on the IP address the client will be addressing. Add the following line after "# Listen <serverip>:631" (using the server's IP address instead of client's 192.168.0.100):
+
Also make sure the server is listening on the IP address the client will use:
Listen 192.168.0.101:631
+
{{hc|/etc/cups/cupsd.conf|
 +
...
 +
Listen <hostname>:631
 +
...
 +
}}
  
To "Show shared printers on the local network" make sure you have the Browsing directive enabled:
+
There are more configuration possibilities, including automatic methods, which are described in detail in [http://localhost:631/help/network.html Using Network Printers].
Browsing On
+
  
After making modifications, restart CUPS.
+
After making any modifications, restart CUPS.
  
On the client system, open up (create if not present) {{ic|/etc/cups/client.conf}} and add the ServerName to match the IP address or the name of the server. Add this line:
+
If CUPS is started using socket activation, create a [[drop-in snippet]] for {{ic|org.cups.cupsd.socket}} so that socket activation also works for remote connections:
ServerName 192.168.0.101
+
{{hc|/etc/systemd/system/org.cups.cupsd.socket.d/override.conf|<nowiki>
 +
[Socket]
 +
ListenStream=631
 +
</nowiki>}}
  
There are more configuration possibilities, including automatic methods, which are described in detail in http://localhost:631/help/network.html <!-- Someone with CUPS installed could rename the link to the page title -->
+
===Enabling browsing===
  
After making modifications, restart CUPS.
+
To enable browsing (shared printer discovery), [[Avahi]] must be installed and running on the server.
 +
If you do not need printer discovery, Avahi is not required on either the server or the client.
  
{{Note|When adding the printer from the client, if using the Internet Printing Protocol (IPP), put the URI as ipp://192.168.0.101:631/printers/<name-of-printer>}}
+
{{Note|Browsing will only work if [[Avahi]] is running before cupsd is started}}
  
====Using a CUPS 1.6.x client with a <= 1.5.x server====
+
To enable browsing, either select ''Share printers connected to this system'' in the web interface, or manually turn on Browsing and set the BrowseAddress:
 
+
{{hc|/etc/cups/cupsd.conf|
As of CUPS version 1.6, the client defaults to IPP 2.0. If the server uses CUPS <= 1.5 / IPP <= 1.1, the client doesn't downgrade the protocol automatically and thus can't communicate with the server. A workaround (undocumented as of 2013-05-07, but see [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=704238 this bug report]) is to put the following in {{ic|/etc/cups/client.conf}}:
+
...
ServerName HOSTNAME-OR-IP-ADDRESS[:PORT]/version=1.1
+
Browsing On
 +
BrowseAddress 192.168.0.*:631
 +
...
 +
}}
  
 
==Between GNU/Linux and Windows==
 
==Between GNU/Linux and Windows==
Line 62: Line 71:
 
====Sharing via IPP====
 
====Sharing via IPP====
  
The '''preferred way''' to connect a Windows client to a Linux print server is using [http://de.wikipedia.org/wiki/Internet_Printing_Protocol IPP]. It's a standard printer protocol based on HTTP, allowing you all ways to profit from port forwarding, tunneling etc.
+
The '''preferred way''' to connect a Windows client to a Linux print server is using [[wikipedia:Internet_Printing_Protocol|IPP]]. It is a standard printer protocol based on HTTP, allowing you all ways to profit from port forwarding, tunneling etc.
 
The configuration is '''very easy''' and this way is less error-prone than using Samba.
 
The configuration is '''very easy''' and this way is less error-prone than using Samba.
 
IPP is natively supported by Windows '''since Windows 2000'''.
 
IPP is natively supported by Windows '''since Windows 2000'''.
 +
{{Note|You may have to add the Internet Printing Client to Windows (''Control Panel->Programs->Turn Windows features on or off->Print and Document Services'')}}
  
To configure the server side proceed as described in the section above to enable browsing.
+
First, configure the server as described in the section [[#Between GNU/Linux systems]].
 
   
 
   
On the Windows computer, go to the printer control panel and choose to 'Add a New Printer'. Next, choose to give a URL. For the URL, type in the location of the printer: http://host_ip_address:631/printers/printer_name (where host_ip_address is the GNU/Linux server's IP address and printer_name is the name of the printer being connected to).
+
On the Windows computer, go to ''Control Panel->Devices and Printers'' and choose to 'Add a printer'. Next, choose 'Select a shared printer by name' and type in the location of the printer:
 +
 
 +
http://''hostname'':631/printers/''printer_name''
 +
 
 +
(where ''hostname'' is the GNU/Linux server's hostname or IP address and ''printer_name'' is the name of the printer being connected to. You can also use the server's fully qualified domain name, if it has one, but you may need to set {{ic|ServerAlias my_fully_qualified_domain_name}} in ''cupsd.conf'' for this to work).
 +
 
 +
{{Note|The 'Add Printer' dialog in Windows is sensitive about the path. The dialogue box suggests the format {{ic|<nowiki>http://computername/printers/printername/.printer</nowiki>}}, which it will not accept. Instead, use the syntax suggested above.
 +
}}
 +
 
 +
{{Note|If you are using '''proxy''' - check used proxy '''exclusions''' twice - it may result in failing to add a printer until reboot even if you will disable proxy at all afterwards (actual for Windows 7).}}
  
 
After this, install the native printer drivers for your printer on the Windows computer. If the CUPS server is set up to use its own printer drivers, then you can just select a generic postscript printer for the Windows client(e.g. 'HP Color LaserJet 8500 PS' or 'Xerox DocuTech 135 PS2'). Then test the print setup by printing a test page.
 
After this, install the native printer drivers for your printer on the Windows computer. If the CUPS server is set up to use its own printer drivers, then you can just select a generic postscript printer for the Windows client(e.g. 'HP Color LaserJet 8500 PS' or 'Xerox DocuTech 135 PS2'). Then test the print setup by printing a test page.
Line 75: Line 94:
  
 
If your client's Windows version is below Windows 2000 or if you experienced troubles with IPP you can also use Samba for sharing.
 
If your client's Windows version is below Windows 2000 or if you experienced troubles with IPP you can also use Samba for sharing.
Note of course that with Samba this involves another complex piece of software. This makes this way '''more difficult to configure''' and thus sometimes also '''more error-prone''', mostly due do authentication problems.
+
Note of course that with Samba this involves another complex piece of software. This makes this way '''more difficult to configure''' and thus sometimes also '''more error-prone''', mostly due to authentication problems.
  
 
To configure Samba on the Linux server, edit {{ic|/etc/samba/smb.conf}} file to allow access to printers. File {{ic|smb.conf}} can look something like this:
 
To configure Samba on the Linux server, edit {{ic|/etc/samba/smb.conf}} file to allow access to printers. File {{ic|smb.conf}} can look something like this:
Line 146: Line 165:
  
 
===Windows server - Linux client===
 
===Windows server - Linux client===
 +
{{Warning|Any special characters in the printer URIs need to be appropriately quoted, or, if your Windows printer name or user passwords have spaces, CUPS will throw a "lpadmin: Bad device-uri" error.
 +
For example:
 +
<code>smb://BEN-DESKTOP/HP Color LaserJet CP1510 series PCL6</code>
 +
 
 +
becomes:
 +
 
 +
<code>smb://BEN-DESKTOP/HP%20Color%20LaserJet%20CP1510%20series%20PCL6</code>
 +
 
 +
This result string can be obtained by running the following command:
 +
$ python2 -c 'import urllib; print "smb://" + urllib.quote("BEN-DESKTOP/HP Color LaserJet CP1510 series PCL6")'
 +
}}
  
 
====Sharing via LPD====
 
====Sharing via LPD====
Line 162: Line 192:
 
The commonly chosen server software is Microsoft's Internet Information Services (IIS).
 
The commonly chosen server software is Microsoft's Internet Information Services (IIS).
  
{{Note|This section is incomplete. Here is a description how to set up ISS in Windows XP and Windows 2000, unfortunately in German [http://www.heise.de/netze/artikel/Ueberall-drucken-221652.html]}}
+
{{Note|This section is incomplete. Here is a description how to set up IIS in Windows XP and Windows 2000, unfortunately in German [http://www.heise.de/netze/artikel/Ueberall-drucken-221652.html]}}
  
 
====Sharing via Samba====
 
====Sharing via Samba====
Line 185: Line 215:
 
  smb://username@hostname/printer_name
 
  smb://username@hostname/printer_name
  
Make sure that the user actually has access to the printer on the Windows computer and select the appropriate drivers. If the computer is located on a domain, make sure the user-name includes the domain:  
+
Make sure that the user actually has access to the printer on the Windows computer and select the appropriate drivers. If the computer is located on a domain, make sure the URI includes the domain:  
 
  smb://username:password@domain/hostname/printer_name
 
  smb://username:password@domain/hostname/printer_name
 
If the network contains many printers you might want to set a preferred printer. To do so use the web interface, go into the printer tab, choose the desired printer and select 'Set as default' from the drop-down list.
 
  
 
=====Manual configuration=====
 
=====Manual configuration=====
 +
 +
{{Accuracy|This should probably use lpadmin instead of editing the config file}}
  
 
For manual configuration stop the CUPS daemon and add your printer to {{ic|/etc/cups/printers.conf}}, which might for example look like this
 
For manual configuration stop the CUPS daemon and add your printer to {{ic|/etc/cups/printers.conf}}, which might for example look like this
Line 214: Line 244:
 
}}
 
}}
  
Then restart the CUPS daemon an try to print a test page.
+
Then restart the CUPS daemon and try to print a test page.
  
To set the preferred printer use the following command
+
=====Finding URIs for Windows print servers=====
# lpoptions -d desired_default_printer_name
+
  
===Troubleshooting===
+
Sometimes Windows is a little less than forthcoming about exact device URIs (device locations).  If having trouble specifying the correct device location in CUPS, run the following command to list all shares available to a certain windows username:
 +
$ smbtree -U ''windowsusername''
 +
This will list every share available to a certain Windows username on the local area network subnet, as long as Samba is set up and running properly.  It should return something like this:
 +
{{bc| WORKGROUP
 +
\\REGULATOR-PC 
 +
\\REGULATOR-PC\Z             
 +
\\REGULATOR-PC\Public       
 +
\\REGULATOR-PC\print$        Printer Drivers
 +
\\REGULATOR-PC\G             
 +
\\REGULATOR-PC\EPSON Stylus CX8400 Series EPSON Stylus CX8400 Series}}
 +
What is needed here is first part of the last line, the resource matching the printer description.  So to print to the EPSON Stylus printer, one would enter:
 +
smb://username.password@REGULATOR-PC/EPSON Stylus CX8400 Series
 +
as the URI into CUPS.
  
If there are any problems, the first thing to do is enable debug information by setting
+
==Remote administration==
{{bc|LogLevel debug}} in {{ic|/etc/cups/cupsd.conf}}.
+
  
Then restart the CUPS daemon and check for error messages in {{ic|/var/log/cups/error_log}}. A convenient way to do so is
+
Once the server is set up as described in [[#Between GNU/Linux systems]], it can also be configured so that it can be remotely administered. Add the allowed hosts to the {{ic|<Location /admin>}} block in {{ic|/etc/cups/cupsd.conf}}, using the same syntax as described in [[#Manual setup]]. Note that three levels of access can be granted:
# tail -f /var/log/cups/error_log
+
which keeps printing new error messages as they occur.
+
  
Note: You can also use the web interface to browse this error file.
+
<Location />          #access to the server
 +
<Location /admin> #access to the admin pages
 +
<Location /admin/conf> #access to configuration files
  
====Can't print with GTK applications====
+
To give remote hosts access to one of these levels, add an {{ic|Allow}} statement to that level's section. An {{ic|Allow}} statement can take one or more of the forms listed below:
 +
Allow from all
 +
Allow from host.domain.com
 +
Allow from *.domain.com
 +
Allow from ip-address
 +
Allow from ip-address/netmask
 +
Allow from @LOCAL
 +
 
 +
Deny statements can also be used. For example, to give full access to all hosts on your local network interfaces, edit {{ic|/etc/cups/cupsd.conf}} to include this:
 +
# Restrict access to the server...
 +
# By default only localhost connections are possible
 +
<Location />
 +
    Order allow,deny
 +
    '''Allow from @LOCAL'''
 +
</Location>
 +
 +
# Restrict access to the admin pages...
 +
<Location /admin>
 +
    Order allow,deny
 +
    '''Allow from @LOCAL'''
 +
</Location>
 +
 +
# Restrict access to configuration files...
 +
<Location /admin/conf>
 +
    AuthType Basic
 +
    Require user @SYSTEM
 +
    Order allow,deny
 +
    '''Allow from @LOCAL'''
 +
</Location>
 +
 
 +
{{Accuracy|CUPS generates a certificate automatically so this should not be an issue}}
 +
 
 +
You might also need to add:
 +
 
 +
DefaultEncryption Never
 +
 
 +
This should avoid the error: 426 - Upgrade Required when using the CUPS web interface from a remote machine.
 +
 
 +
==Troubleshooting==
 +
 
 +
See [[CUPS/Troubleshooting]] for general troubleshooting tips.
 +
 
 +
===Cannot print with GTK applications===
 
If you get "getting printer information failed" when you try to print from gtk-applications, add this line to your {{ic|/etc/hosts}}:
 
If you get "getting printer information failed" when you try to print from gtk-applications, add this line to your {{ic|/etc/hosts}}:
 
   # serverip some.name.org ServersHostname
 
   # serverip some.name.org ServersHostname
 +
 +
=== Unable to add/modify a printer via SAMBA ===
 +
 +
When adding a or modifying a printer via SAMBA, the interface hangs at 100% CPU for about 30 seconds and then returns the message
 +
 +
Unable to get list of printer drivers: Success
 +
 +
This is a known bug in Gutenprint (https://bugs.archlinux.org/task/43708). The workaround is to uninstall Gutenprint and install only foomatic-db.
 +
 +
  lpinfo -m
 +
 +
should then return the list of drivers instead of just the "Success" message.
 +
 +
=== Permission errors on Windows ===
 +
 +
Some users fixed 'NT_STATUS_ACCESS_DENIED' (Windows clients) errors by using a slightly different syntax:
 +
smb://workgroup/username:password@hostname/printer_name
  
 
==Other operating systems==
 
==Other operating systems==
More information on interfacing CUPS with other printing systems can be found in the CUPS manual, e.g. on http://localhost:631/sam.html#PRINTING_OTHER
+
More information on interfacing CUPS with other printing systems can be found in the CUPS manual, e.g. on http://localhost:631/help/network.html

Latest revision as of 01:02, 23 August 2016

Related articles

This article contains instruction on sharing printers between systems, be it between two GNU/Linux systems or between a GNU/Linux system and Microsoft Windows.

Between GNU/Linux systems

The server can be configured using either the web interface or by manually editing /etc/cups/cupsd.conf. To configure the client, see CUPS#Remote CUPS servers.

Using the web interface

Open up the web interface to the server, select the Administration tab, look under the Server heading, and enable the "Share printers connected to this system" option. Save your change by clicking on the Change Settings button. The server will automatically restart.

For more complex configurations, you can directly edit the /etc/cups/cupsd.conf file by selecting Edit Configuration File. See #Manual setup for more information.

Manual setup

On the server computer (the one directly connected to the printer), allow access to the server by modifying the location directive. For instance:

/etc/cups/cupsd.conf
<Location />
    Order allow,deny
    Allow localhost
    Allow 192.168.0.*
</Location>
...

Also make sure the server is listening on the IP address the client will use:

/etc/cups/cupsd.conf
...
Listen <hostname>:631
...

There are more configuration possibilities, including automatic methods, which are described in detail in Using Network Printers.

After making any modifications, restart CUPS.

If CUPS is started using socket activation, create a drop-in snippet for org.cups.cupsd.socket so that socket activation also works for remote connections:

/etc/systemd/system/org.cups.cupsd.socket.d/override.conf
[Socket]
ListenStream=631

Enabling browsing

To enable browsing (shared printer discovery), Avahi must be installed and running on the server. If you do not need printer discovery, Avahi is not required on either the server or the client.

Note: Browsing will only work if Avahi is running before cupsd is started

To enable browsing, either select Share printers connected to this system in the web interface, or manually turn on Browsing and set the BrowseAddress:

/etc/cups/cupsd.conf
...
Browsing On
BrowseAddress 192.168.0.*:631
...

Between GNU/Linux and Windows

Linux server - Windows client

Sharing via IPP

The preferred way to connect a Windows client to a Linux print server is using IPP. It is a standard printer protocol based on HTTP, allowing you all ways to profit from port forwarding, tunneling etc. The configuration is very easy and this way is less error-prone than using Samba. IPP is natively supported by Windows since Windows 2000.

Note: You may have to add the Internet Printing Client to Windows (Control Panel->Programs->Turn Windows features on or off->Print and Document Services)

First, configure the server as described in the section #Between GNU/Linux systems.

On the Windows computer, go to Control Panel->Devices and Printers and choose to 'Add a printer'. Next, choose 'Select a shared printer by name' and type in the location of the printer:

http://hostname:631/printers/printer_name

(where hostname is the GNU/Linux server's hostname or IP address and printer_name is the name of the printer being connected to. You can also use the server's fully qualified domain name, if it has one, but you may need to set ServerAlias my_fully_qualified_domain_name in cupsd.conf for this to work).

Note: The 'Add Printer' dialog in Windows is sensitive about the path. The dialogue box suggests the format http://computername/printers/printername/.printer, which it will not accept. Instead, use the syntax suggested above.
Note: If you are using proxy - check used proxy exclusions twice - it may result in failing to add a printer until reboot even if you will disable proxy at all afterwards (actual for Windows 7).

After this, install the native printer drivers for your printer on the Windows computer. If the CUPS server is set up to use its own printer drivers, then you can just select a generic postscript printer for the Windows client(e.g. 'HP Color LaserJet 8500 PS' or 'Xerox DocuTech 135 PS2'). Then test the print setup by printing a test page.

Sharing via Samba

If your client's Windows version is below Windows 2000 or if you experienced troubles with IPP you can also use Samba for sharing. Note of course that with Samba this involves another complex piece of software. This makes this way more difficult to configure and thus sometimes also more error-prone, mostly due to authentication problems.

To configure Samba on the Linux server, edit /etc/samba/smb.conf file to allow access to printers. File smb.conf can look something like this:

/etc/samba/smb.conf
[global]
workgroup=Heroes
server string=Arch Linux Print Server
security=user

[printers]
    comment=All Printers
    path=/var/spool/samba
    browseable=yes
    # to allow user 'guest account' to print.
    guest ok=no
    writable=no
    printable=yes
    create mode=0700
    write list=@adm root yourusername

That should be enough to share the printer, yet adding an individual printer entry may be desirable:

/etc/samba/smb.conf
[ML1250]
    comment=Samsung ML-1250 Laser Printer
    printer=ml1250
    path=/var/spool/samba
    printing=cups
    printable=yes
    printer admin=@admin root yourusername
    user client driver=yes
    # to allow user 'guest account' to print.
    guest ok=no
    writable=no
    write list=@adm root yourusername
    valid users=@adm root yourusername

Please note that this assumes configuration was made so that users must have a valid account to access the printer. To have a public printer, set guest ok to yes, and remove the valid users line. To add accounts, set up a regular GNU/Linux account and then set up a Samba password on the server. For instance:

# useradd yourusername
# smbpasswd -a yourusername


After this, restart the Samba daemon.

Obviously, there are a lot of tweaks and customizations that can be done with setting up a Samba print server, so it is advised to look at the Samba and CUPS documentation for more help. The smb.conf.example file also has some good samples that might warrant imitating.

Windows server - Linux client

Warning: Any special characters in the printer URIs need to be appropriately quoted, or, if your Windows printer name or user passwords have spaces, CUPS will throw a "lpadmin: Bad device-uri" error.

For example: smb://BEN-DESKTOP/HP Color LaserJet CP1510 series PCL6

becomes:

smb://BEN-DESKTOP/HP%20Color%20LaserJet%20CP1510%20series%20PCL6

This result string can be obtained by running the following command:

$ python2 -c 'import urllib; print "smb://" + urllib.quote("BEN-DESKTOP/HP Color LaserJet CP1510 series PCL6")'

Sharing via LPD

Windows 7 has a built-in LPD server - using it will probably be the easiest approach as it does neither require an installation of Samba on the client nor heavy configuration on the server. It can be activated in the Control Panel under Programs -> Activate Windows functions in the section Print services. The printer must have shared activated in its properties. Use a share name without any special characters like spaces, commas, etc.

Then the printer can be added in CUPS, choosing LPD protocol. The printer address will look like this:

# lpd://windowspc/printersharename

Before adding the printer, you will most likely have to install an appropriate printer driver depending on your printer model. Generic PostScript or RAW drivers might also work.

Sharing via IPP

As above, IPP is also the preferred protocol for printer sharing. However this way might be a bit more difficult than the native Samba approach below, since you need a greater effort to set up an IPP-Server on Windows. The commonly chosen server software is Microsoft's Internet Information Services (IIS).

Note: This section is incomplete. Here is a description how to set up IIS in Windows XP and Windows 2000, unfortunately in German [1]

Sharing via Samba

A much simpler way is using Window's native printer sharing via Samba. There is almost no configuration needed, and all of it can be done from the CUPS Backend. As above noted, if there are any problems the reason is mostly related to authentication trouble and Windows access restrictions.

On the server side enable sharing for your desired printer and ensure that the user on the client machine has the right to access the printer.

The following section describes how to set up the client, assuming that both daemons (cupsd and smbd) are running.

Configuration using the web interface

The Samba CUPS back-end is enabled by default, if for any reason it is not activate it by entering the following command and restarting CUPS.

# ln -s $(which smbspool) /usr/lib/cups/backend/smb

Next, simply log in on the CUPS web interface and choose to add a new printer. As a device choose "Windows Printer via SAMBA".

For the device location, enter:

smb://username:password@hostname/printer_name

Or without a password:

smb://username@hostname/printer_name

Make sure that the user actually has access to the printer on the Windows computer and select the appropriate drivers. If the computer is located on a domain, make sure the URI includes the domain:

smb://username:password@domain/hostname/printer_name
Manual configuration

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: This should probably use lpadmin instead of editing the config file (Discuss in Talk:CUPS/Printer sharing#)

For manual configuration stop the CUPS daemon and add your printer to /etc/cups/printers.conf, which might for example look like this

/etc/cups/printers.conf
<DefaultPrinter MyPrinter>
AuthInfoRequired username,password
Info My printer via SAMBA
Location In my Office
MakeModel Samsung ML-1250 - CUPS+Gutenprint v5.2.7        # <= use 'lpinfo -m' to list available models
DeviceURI smb://username:password@hostname/printer_name   # <= server URI as described in previous section
State Idle
Type 4
Accepting Yes
Shared No
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
AllowUser yourusername                                    # <= do not forget to change this
OpPolicy default
ErrorPolicy stop-printer
</Printer>

Then restart the CUPS daemon and try to print a test page.

Finding URIs for Windows print servers

Sometimes Windows is a little less than forthcoming about exact device URIs (device locations). If having trouble specifying the correct device location in CUPS, run the following command to list all shares available to a certain windows username:

$ smbtree -U windowsusername

This will list every share available to a certain Windows username on the local area network subnet, as long as Samba is set up and running properly. It should return something like this:

 WORKGROUP
	\\REGULATOR-PC   		
		\\REGULATOR-PC\Z              	
		\\REGULATOR-PC\Public         	
		\\REGULATOR-PC\print$         	Printer Drivers
		\\REGULATOR-PC\G              	
		\\REGULATOR-PC\EPSON Stylus CX8400 Series	EPSON Stylus CX8400 Series

What is needed here is first part of the last line, the resource matching the printer description. So to print to the EPSON Stylus printer, one would enter:

smb://username.password@REGULATOR-PC/EPSON Stylus CX8400 Series

as the URI into CUPS.

Remote administration

Once the server is set up as described in #Between GNU/Linux systems, it can also be configured so that it can be remotely administered. Add the allowed hosts to the <Location /admin> block in /etc/cups/cupsd.conf, using the same syntax as described in #Manual setup. Note that three levels of access can be granted:

<Location />           #access to the server
<Location /admin>	#access to the admin pages
<Location /admin/conf>	#access to configuration files

To give remote hosts access to one of these levels, add an Allow statement to that level's section. An Allow statement can take one or more of the forms listed below:

Allow from all
Allow from host.domain.com
Allow from *.domain.com
Allow from ip-address
Allow from ip-address/netmask
Allow from @LOCAL

Deny statements can also be used. For example, to give full access to all hosts on your local network interfaces, edit /etc/cups/cupsd.conf to include this:

# Restrict access to the server...
# By default only localhost connections are possible
<Location />
   Order allow,deny
   Allow from @LOCAL
</Location>

# Restrict access to the admin pages...
<Location /admin>
   Order allow,deny
   Allow from @LOCAL
</Location>

# Restrict access to configuration files...
<Location /admin/conf>
   AuthType Basic
   Require user @SYSTEM
   Order allow,deny
   Allow from @LOCAL
</Location>

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: CUPS generates a certificate automatically so this should not be an issue (Discuss in Talk:CUPS/Printer sharing#)

You might also need to add:

DefaultEncryption Never

This should avoid the error: 426 - Upgrade Required when using the CUPS web interface from a remote machine.

Troubleshooting

See CUPS/Troubleshooting for general troubleshooting tips.

Cannot print with GTK applications

If you get "getting printer information failed" when you try to print from gtk-applications, add this line to your /etc/hosts:

 # serverip 	some.name.org 	ServersHostname

Unable to add/modify a printer via SAMBA

When adding a or modifying a printer via SAMBA, the interface hangs at 100% CPU for about 30 seconds and then returns the message

Unable to get list of printer drivers: Success

This is a known bug in Gutenprint (https://bugs.archlinux.org/task/43708). The workaround is to uninstall Gutenprint and install only foomatic-db.

 lpinfo -m

should then return the list of drivers instead of just the "Success" message.

Permission errors on Windows

Some users fixed 'NT_STATUS_ACCESS_DENIED' (Windows clients) errors by using a slightly different syntax:

smb://workgroup/username:password@hostname/printer_name

Other operating systems

More information on interfacing CUPS with other printing systems can be found in the CUPS manual, e.g. on http://localhost:631/help/network.html