Linux局域网共享打印机(实用型文档)

参考博客:https://blog.csdn.net/u012375509/article/details/82024135

https://blog.csdn.net/qasxed/article/details/41253081

用的打印机放置的比较远,而且没有专门的打印电脑,为此需要架设局域网共享打印

这里选择了BeagleBone-Black作为终端,已经烧录Debian系统,用网线连接至局域网,USB插入HP LaserJet 1020打印机数据线

(翻找出来的BBB)


0.设备与环境

  1. BeagleBone-black(简称BBB) ,运行Debian系统
  2. HP LaserJet 1020打印机,数据线插在了BBB的USB接口上
  3. 个人电脑上需安装HP LaserJet 1020打印机驱动

1.BBB上配置

a.安装HPLIP、CUPS

HPLIP(Linux Imaging and Printing Object以前有hpijs, hpoj(hpijs以前是一个单独的项目,但是ghostscript也包含了这个项目。hpoj是针对officejet的。)等开源项目,零散但是有非常有用,其中很多是非官方的,hplip是hpijs和hpoj的整合,受HP官方支持。HPLIP项目包括二进制打印机驱动(HPIJS打印机),以及打印机的维护工具(检查墨水量、清洁和校正打印头,等等)。由于该项目的支持,几乎所有的惠普打印机和一体机(打印/ 扫描/ 复印)都可以正常工作。

CUPS(Common UNIX Printing System,通用Unix打印系统)是Fedora Core3中支持的打印系统,它主要是使用IPP(Internet Printing Protocol)来管理打印工作及队列,但同时也支持"LPD"(Line Printer Daemon)和"SMB"(Server Message Block)以及AppSocket等通信协议。

$sudo apt install hplip cups

b.将用户添加到用户组lpadmin中(这里我的用户为sements)

$sudo usermod -a -G lpadmin sements

c.修改配置文件cupsd.conf

$sudo cp /etc/cups/cupsd.conf /etc/cups/cupsd.conf.bak     #备份
$sudo vim /etc/cups/cupsd.conf

需要修改几处:

  • Listen localhost:631 修改为 Listen 0.0.0.0:631
  • 在 <Location />, <Location /admin> ,<Location /admin/conf> 三个节点中添加 Allow all

修改后文件如下

sements@beaglebone:/etc/cups$ cat /etc/cups/cupsd.conf
#
# 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 0.0.0.0:631
Listen /var/run/cups/cups.sock

# Show shared printers on the local network.
Browsing On
BrowseLocalProtocols dnssd

# Default authentication type, when authentication is required...
DefaultAuthType Basic

# Web interface setting...
WebInterface Yes

# Restrict access to the server...
<Location />
  Allow all
  Order allow,deny
</Location>

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

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

# Restrict access to log files...
<Location /admin/log>
  AuthType Default
  Require user @SYSTEM
  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
  </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 Default
    Require user @SYSTEM
    Order deny,allow
  </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>
    AuthType Default
    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>

# 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>
    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 Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document>
    AuthType Default
    Require user @OWNER @SYSTEM
    Order deny,allow
  </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>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </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>
    AuthType Default
    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>
    AuthType Default
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>

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

d.重启CUPS服务

$sudo service cups restart

e.配置打印机共享

在浏览器中输入 https://你板子的IP地址:631/ ,点击“Administration” -> “Add Printer”

这里可能会要求你输入用户名与密码,输入你已加入lpadmin组中的用户名以及密码

选中连接上BBB的打印机,这里我的是HP LaserJet 1020

对打印机进行命名,记得勾选“Share This Printer”

选择打印机制造商和型号,这里我的是HP公司的HP LaserJet 1020

到printers页面选择你的打印机,复制地址栏的地址

2.使用PC的配置

a.打开 控制面板 -> 硬件和声音 -> 添加打印机 在弹出窗口选择 “我所需的打印机未列出”

b.在弹出窗口里将你的打印机地址填入,如果开头为https,将其修改为http

至此,添加打印机的流程完成


猜你喜欢

转载自blog.csdn.net/u013662665/article/details/88401982