从 Windows 打印到 Ubuntu 共享打印机

从 Windows 打印到 Ubuntu 共享打印机

我有两台打印机,一台戴尔 V715w 和一台 HP LaserJet P2015,通过 USB 连接到运行 Ubuntu 的计算机,以便通过 CUPS 与我家中的所有笔记本电脑共享。我在 Ubuntu 计算机上本地安装了这两台打印机,配置了 CUPS,启动了它,并在本地测试了打印,没有任何问题。

我顺利地连接到了所有笔记本电脑上的 HP 打印机,并测试了所有笔记本电脑上的打印,同样没有任何问题。

我尝试在四台运行 Vista 的笔记本电脑中的两台上连接戴尔打印机,但没有成功。它出现以下错误:

Windows 无法连接到打印机。请确保您已正确输入名称,并且打印机已连接到网络。

戴尔打印机内置无线网络,但我更喜欢使用 USB。我非常确定我安装正确,因为它确实可以打印,只是不通过网络。“服务器”计算机和我尝试过的其中一台笔记本电脑通过以太网直接连接到我的无线路由器。有什么可能导致它出错吗?

根据要求,cups 错误日志:

E [13/Jun/2011:16:23:06 -0400] Unable to remove temporary file "/var/spool/cups/tmp/.hplip" - Is a directory
E [13/Jun/2011:16:33:22 -0400] Unable to remove temporary file "/var/spool/cups/tmp/.hplip" - Is a directory
E [13/Jun/2011:16:46:31 -0400] [cups-driverd] Bad driver information file "/usr/share/cups/drv/sample.drv"!
E [13/Jun/2011:17:01:42 -0400] [cups-driverd] Bad driver information file "/usr/share/cups/drv/sample.drv"!
W [13/Jun/2011:17:25:41 -0400] Duplicate listen address "0.0.0.0" ignored!
W [13/Jun/2011:17:25:41 -0400] Duplicate listen address "::" ignored!
E [13/Jun/2011:17:25:42 -0400] Unable to remove temporary file "/var/spool/cups/tmp/.hplip" - Is a directory
E [13/Jun/2011:17:25:42 -0400] Unable to bind socket for address 0.0.0.0:631 - Address already in use.
E [13/Jun/2011:17:25:42 -0400] Unable to bind socket for address :::631 - Address already in use.
E [13/Jun/2011:17:25:42 -0400] Unable to bind broadcast socket - Address already in use.
W [13/Jun/2011:17:26:28 -0400] Duplicate listen address "0.0.0.0" ignored!
W [13/Jun/2011:17:26:28 -0400] Duplicate listen address "::" ignored!
E [13/Jun/2011:17:26:28 -0400] Unable to remove temporary file "/var/spool/cups/tmp/.hplip" - Is a directory
E [13/Jun/2011:17:26:28 -0400] Unable to bind socket for address 0.0.0.0:631 - Address already in use.
E [13/Jun/2011:17:26:28 -0400] Unable to bind socket for address :::631 - Address already in use.
E [13/Jun/2011:17:26:28 -0400] Unable to bind broadcast socket - Address already in use.
E [13/Jun/2011:17:27:22 -0400] Missing printer-uri, job-uri, or ppd-name attribute!
E [13/Jun/2011:17:27:22 -0400] Returning IPP client-error-bad-request for windows-ext (no URI) from 192.168.1.2
E [13/Jun/2011:17:30:20 -0400] Missing printer-uri, job-uri, or ppd-name attribute!
E [13/Jun/2011:17:30:20 -0400] Returning IPP client-error-bad-request for windows-ext (no URI) from 192.168.1.6
E [13/Jun/2011:17:33:39 -0400] Missing printer-uri, job-uri, or ppd-name attribute!
E [13/Jun/2011:17:33:39 -0400] Returning IPP client-error-bad-request for windows-ext (no URI) from 192.168.1.3
E [13/Jun/2011:17:37:16 -0400] Missing printer-uri, job-uri, or ppd-name attribute!
E [13/Jun/2011:17:37:16 -0400] Returning IPP client-error-bad-request for windows-ext (no URI) from 192.168.1.5
E [13/Jun/2011:18:01:11 -0400] [cups-driverd] Bad driver information file "/usr/share/cups/drv/sample.drv"!
E [13/Jun/2011:18:02:08 -0400] [cups-driverd] Bad driver information file "/usr/share/cups/drv/sample.drv"!
E [13/Jun/2011:18:03:25 -0400] [cups-driverd] Bad driver information file "/usr/share/cups/drv/sample.drv"!
E [13/Jun/2011:18:57:20 -0400] [Job 3] 
E [13/Jun/2011:18:57:25 -0400] [Job 3] 
W [13/Jun/2011:18:58:45 -0400] Duplicate listen address "0.0.0.0" ignored!
W [13/Jun/2011:18:58:45 -0400] Duplicate listen address "::" ignored!
E [13/Jun/2011:18:58:45 -0400] Unable to remove temporary file "/var/spool/cups/tmp/.hplip" - Is a directory
E [13/Jun/2011:18:58:45 -0400] Unable to bind socket for address 0.0.0.0:631 - Address already in use.
E [13/Jun/2011:18:58:45 -0400] Unable to bind socket for address :::631 - Address already in use.
E [13/Jun/2011:18:58:45 -0400] Unable to bind broadcast socket - Address already in use.
E [13/Jun/2011:19:01:54 -0400] [cups-driverd] Bad driver information file "/usr/share/cups/drv/sample.drv"!
E [13/Jun/2011:19:06:25 -0400] Missing printer-uri, job-uri, or ppd-name attribute!
E [13/Jun/2011:19:06:25 -0400] Returning IPP client-error-bad-request for windows-ext (no URI) from 192.168.1.2

cupsd.conf,也按要求:

LogLevel warn
MaxLogSize 0
SystemGroup lpadmin
# Allow remote access
Port 631
Listen /var/run/cups/cups.sock
Listen 631
# Share local printers on the local network.
Browsing On
BrowseOrder allow,deny
BrowseRemoteProtocols
BrowseAllow all
BrowseAddress @LOCAL
BrowseLocalProtocols CUPS dnssd
DefaultAuthType Basic
<Location />
  # Allow shared printing...
  Order allow,deny
  Allow @LOCAL
</Location>
<Location /admin>
  # Restrict access to the admin pages...
  Order allow,deny
</Location>
<Location /admin/conf>
  AuthType Default
  Require user @SYSTEM
  # Restrict access to the configuration files...
  Order allow,deny
</Location>
<Policy default>
  <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 CUPS-Get-Document>
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>
  <Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default CUPS-Get-Devices>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>
  <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 CUPS-Accept-Jobs CUPS-Reject-Jobs>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>
  <Limit Cancel-Job CUPS-Authenticate-Job>
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>
  <Limit All>
    Order deny,allow
  </Limit>
</Policy>
<Policy authenticated>
  <Limit Create-Job Print-Job Print-URI>
  AuthType Default
  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 CUPS-Move-Job CUPS-Get-Document>
AuthType Default
Require user @OWNER @SYSTEM
Order deny,allow
  </Limit>
  <Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default>
  AuthType Default
  Require user @SYSTEM
  Order deny,allow
    </Limit>
  <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 CUPS-Accept-Jobs CUPS-Reject-Jobs>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
      </Limit>
  <Limit Cancel-Job CUPS-Authenticate-Job>
      AuthType Default
      Require user @OWNER @SYSTEM
      Order deny,allow
        </Limit>
  <Limit All>
        Order deny,allow
          </Limit>
</Policy>

答案1

尝试通过 Samba 进行打印总是让我头疼。我建议你使用互联网打印协议 (IPP)反而。

首先确保您的打印服务器的 CUPS 中已启用 IPP:

  1. 浏览至http://本地主机:631/在打印服务器机器上。
  2. 前往行政标签。
  3. 确保共享连接到此系统的打印机允许从 Internet 打印已检查。
  4. 点击更改设置按钮。
  5. CUPS 将重新启动以使您的更改生效。

然后,在 Vista 机器上设置打印机:

  1. 转到开始 > 设备和打印机。
  2. 点击添加打印机在工具栏上。
  3. 点击添加网络、无线或蓝牙打印机
  4. 点击我想要的打印机未列出
  5. 选择通过名称选择共享打印机
  6. 输入http://<hostname>:631/printers/<printer-name>其中<hostname>托管打印机的 Ubuntu 计算机的主机名或 IP 地址,<printer-name>以及队列名称由 CUPS 管理界面显示。
  7. Windows 应该连接到您的打印机。
  8. 现在将提示您为打印机选择驱动程序。您可以选择通用的制造商和MS Publisher 照排机打印机驱动程序,它只会让 Windows 将打印作业发送到 CUPS后记格式化并允许 CUPS 使用其驱动程序,或者如果您需要使用它提供的任何高级功能,请选择打印机的驱动程序。(在我看来,前者通常效果更好。)
  9. 点击好的
  10. Windows 确认您已成功安装打印机。单击下一个
  11. 如果愿意,您可以选择打印测试页来验证一切是否正常。

答案2

在我的生产服务器上,我使用 Debian Bullseye 在 docker 容器中运行 cups 版本 2.3.1。

我的客户端是Windows 10。

我在 docker 容器中的 /var/log/cups/error_log 中记录了以下错误:

缺少打印机 uri、作业 uri 或 ppd 名称属性。E [24/Jan/2020:11:47:33 +0000] [客户端 354] 从 192.168.0.140 返回 windows-ext(无 URI)的 IPP 客户端错误错误请求。

我必须执行 Patches 描述的所有上述操作。但是,错误仍然存​​在。对我有用的附加步骤是在我的 Windows 10 客户端上指定 cups 服务器的用户名和密码。在我的情况下,默认用户名和密码都是“print”。这是 olbat/cups docker 容器的默认设置。

为了设置密码和用户名,我导航到“设置”、“打印机和扫描仪”,最后是所连接打印机下的“管理”。在打印机的设置页面上,我选择了“打印机属性”。接下来,我选择了“端口”选项卡并单击了“配置端口...”按钮。

在“配置 Internet 端口”窗口中​​,我选择了“使用指定的用户帐户”选项按钮,并输入了用户名和密码。然后,我便能够打印测试页,而 /var/log/cups/error.log 文件中不会重复出现上述错误。

希望这可以帮助 :-)

答案3

在 Windows 上要检查的另一件事是Software\Policies\Microsoft\Windows NT\Printers\DisableHTTPPrinting策略。当此键设置为 true 时,即使 Windows 成功安装了 CUPS 打印机,文档也不会出现在打印机队列中。

相关内容