我已经使用 Web 界面设置了 CUPS 服务器。遗憾的是,我无法通过执行以下步骤添加打印机:
- 浏览器(REMOTE_SERVER_IP:631)
- 管理选项卡
- 本地打印机
- 惠普打印机 (HPLIP)
- 联系
- 添加打印机(名称和所有好东西)
- 选择型号
- 选择驱动程序
- 错误
此时我收到消息:Unable to add printer: Unauthorized
。我的配置文件如下所示:
# Disable cups internal logging - use logrotate instead
MaxLogSize 0
# Log general information in error_log - change "warn" to "debug"
# for troubleshooting...
LogLevel warn
#PageLogFormat
Listen /run/cups/cups.sock
Listen 0.0.0.0:631
Port 631
BrowseAddress *.*.*.*:631
BrowseAllow all
# Show shared printers on the local network.
Browsing On
BrowseLocalProtocols all
# Default authentication type, when authentication is required...
DefaultAuthType None
# Web interface setting...
WebInterface Yes
# Restrict access to the server...
<Location />
Order allow,deny
Allow All
</Location>
# Restrict access to the admin pages...
<Location /admin>
Order allow,deny
Allow All
</Location>
# Restrict access to configuration files...
<Location /admin/conf>
Order allow,deny
Allow All
</Location>
# Restrict access to log files...
<Location /admin/log>
Order allow,deny
Allow All
</Location>
我正在使用以下Dockerfile构建并开始整个事情。我还在图像中提供了一个新用户。
我缺少什么?
答案1
您还需要添加操作权限
<Policy default>
<Limit All>
Order allow,deny
Allow all
</Limit>
</Policy>
对于我的配置,我使用Allow @LOCAL
而不是Allow all
这样我将接受所有本地连接,但您的要求可能有所不同。
看来这些Location
设置是递归的,所以有足够的
<Location />
Order allow,deny
Allow all
</Location>
所有其他路径(/admin 等)都将包含在内。
答案2
也许你已经解决了这个问题,但我也遇到了同样的问题。通过将“订单拒绝,允许”更改为“订单允许,拒绝”并删除所有身份验证内容来解决此问题。
这是我的配置文件:
#
# Configuration file for the CUPS scheduler. See "man cupsd.conf" for a
# complete description of this file.
#
# Log general information in error_log - change "warn" to "debug"
# for troubleshooting...
LogLevel warn
PageLogFormat
# Deactivate CUPS' internal logrotating, as we provide a better one, especially
# LogLevel debug2 gets usable now
MaxLogSize 0
# Only listen for connections from the local machine.
Listen 631
Listen /var/run/cups/cups.sock
# Show shared printers on the local network.
Browsing Off
BrowseLocalProtocols dnssd
# Default authentication type, when authentication is required...
DefaultAuthType None
# Web interface setting...
WebInterface Yes
# Restrict access to the server...
<Location />
Order allow,deny
Allow all
</Location>
# Restrict access to the admin pages...
<Location /admin>
Order allow,deny
Allow all
</Location>
# Restrict access to configuration files...
<Location /admin/conf>
AuthType None
Order allow,deny
</Location>
# Restrict access to log files...
<Location /admin/log>
AuthType None
Order allow,deny
</Location>
# Set the default printer/job policies...
<Policy default>
# Job/subscription privacy...
JobPrivateAccess default
JobPrivateValues default
SubscriptionPrivateAccess default
SubscriptionPrivateValues default
# Job-related operations must be done by the owner or an administrator...
<Limit Create-Job Print-Job Print-URI Validate-Job>
Order deny,allow
</Limit>
<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 Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document>
#Require user @OWNER @SYSTEM
#Order deny,allow
Order allow,deny
</Limit>
# All administration operations require an administrator to authenticate...
<Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default CUPS-Get-Devices>
AuthType None
Order allow,deny
</Limit>
# All printer operations require a printer operator to authenticate...
<Limit Pause-Printer Resume-Printer 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 Cancel-Jobs CUPS-Accept-Jobs CUPS-Reject-Jobs>
Order allow,deny
</Limit>
# Only the owner or an administrator can cancel or authenticate a job...
<Limit Cancel-Job CUPS-Authenticate-Job>
Order allow,deny
</Limit>
<Limit All>
Order allow,deny
</Limit>
</Policy>
# Set the authenticated printer/job policies...
<Policy authenticated>
# Job/subscription privacy...
JobPrivateAccess default
JobPrivateValues default
SubscriptionPrivateAccess default
SubscriptionPrivateValues default
# Job-related operations must be done by the owner or an administrator...
<Limit Create-Job Print-Job Print-URI Validate-Job>
Order allow,deny
</Limit>
<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 Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document>
Order allow,deny
</Limit>
# All administration operations require an administrator to authenticate...
<Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default>
Order allow,deny
</Limit>
# All printer operations require a printer operator to authenticate...
<Limit Pause-Printer Resume-Printer 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 Cancel-Jobs CUPS-Accept-Jobs CUPS-Reject-Jobs>
Order allow,deny
</Limit>
# Only the owner or an administrator can cancel or authenticate a job...
<Limit Cancel-Job CUPS-Authenticate-Job>
Order allow,deny
</Limit>
<Limit All>
Order allow,deny
</Limit>
</Policy>
答案3
您可以添加一个用户作为 cups 的管理员,而不是允许所有用户。
最简单的方法是将用户添加到lpadmin
组中。
检查一下: 如何启用对 CUPS 中管理页面的远程访问
答案4
我在尝试添加打印机时也遇到了“未经授权”的错误。更多搜索显示使用 Google Chrome 访问 CUPS 2.2.7 时出现问题。它不会询问您的用户名和密码,直接进入“未经授权”。 (在 Ubuntu 18.04 LTS 上,CUPS 2.2.7 是默认值。)
使用不同的浏览器,特别是 Firefox,是一个简单的解决方法。