Installing Cups & HPLIP
Friday, October 9th 2020
Sometimes HP Printers and Linux aren’t just the plug-and-play they should have been out of the box… and every time I need to set up mine for network sharing I have to use Google to refresh my memory. So I hope with those tips I can help someone forgetful as me in this simple endeavour.
If you, like me, have an aging HP Printer that doesn’t have integrated wifi, sharing it over your local network can be simple as plugging it into your NAS or Router, however, sometimes the software won’t recognize it or won’t have the proprietary plugins for it. This can be solved by using your computer, home server or a RaspberryPi; for that we will need CUPS and HPLIP (HP Linux Image Processing), use your package manager to install them. For debian-ish distros you can use:
$ sudo apt install cups hplip
CUPS
After the installation, the daemon needs to be enabled and started:
$ sudo systemctl enable --now cups.service
Easy, right? Now we only need to configure it, this will enable sharing and remote access in your LAN.
$ sudo $EDITOR /etc/cups/cupsd.conf
Modify only the following parameters:
(...)
Listen 631
# Web interface setting...
WebInterface Yes
# Restrict access to the server...
<Location />
Order allow,deny
Allow @LOCAL
</Location>
# Restrict access to the admin pages...
<Location /admin>
AuthType Default
Require valid-user
Order allow,deny
Allow @LOCAL
</Location>
(...)
The last step is to add your user to the printer group,
$ sudo usermod -a -G lpadmin,lp $USER
and refresh group memberships:
$ sudo sync /etc/gshadow
$ sudo grpck
Voilà, CUPS is up & running 😃 This should cover any Linux/Mac devices in your network.
(*) You can access the web interface at https://$YOUR_LOCAL_IP:631/
HPLIP
Now we need to get HP’s proprietary plugin before adding your printer:
$ sudo hp-plugin -i
Read the instructions on the screen and, when asked, answer as follows:
**d** Download plug-in from HP (recommended)
Do you accept the license terms for the plug-in (y=yes*, n=no, q=quit) ? **y**
Now it’s time to add your printer (verify if it is properly connected and turned on):
$ sudo hp-setup -i
Print a test page, if everything goes well now you can use your printer as far your wifi goes!
SAMBA (Optional)
If you have a windows device, you can share your printer via SAMBA:
$ sudo apt install samba
$ sudo $EDITOR /etc/samba/smb.conf
(...)
[printers]
comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
guest ok = yes
read only = yes
create mask = 0700
(...)