Setup a shared scanner
mouse 3033 · person cloud · link
Last update
2021-03-22
2021
03-22
« — »
1
2
3
4
5
6
7
8
9
10
11
12
apt-get install sane sane-utils

scanimage -L # check if a local scanner is found

# add hostnames and/or IP addresses/subnets
pico /etc/sane.d/saned.conf # eg: localhost, 127.0.0.1 and 192.168.1.0/24

# enable local users to see the scanner
adduser username scanner

systemctl enable saned.socket
systemctl start  saned.socket

Configure a client host:

1
2
3
4
# edit /etc/sane.d/net.conf:
#   - uncomment the net backend entry
#   - and add the IP address/hostname of the sane server
scanimage -L # check the remote scanner is found

On windows you can use SaneTwain, on Android the SaneDroid app.

Note: If your sane-utils < 1.0.25 is broken under systemd, fix it with these steps:

1
apt-get install libsystemd-dev

In /lib/systemd/system/saned@.service set StandardInput/Output/Error=socket and append Alias=saned.service to [Install] section:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# /lib/systemd/system/saned@.service
[Unit]
Description=Scanner Service
Requires=saned.socket

[Service]
ExecStart=/usr/sbin/saned
User=saned
Group=saned
StandardInput=socket
StandardOutput=socket
StandardError=socket
Environment=SANE_CONFIG_DIR=/etc/sane.d
# Environment=SANE_CONFIG_DIR=/etc/sane.d SANE_DEBUG_DLL=255

[Install]
Also=saned.socket
Alias=saned.service
1
2
3
systemctl daemon-reload
systemctl enable  saned.socket
systemctl restart saned.socket

fix permissions on USB device

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# FIX for /lib/udev/rules.d/60-libsane.rules missing setfacl command
#
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=918358
# libsane:amd64: Missing permissions for scanner group on usb device
#
# reload rules: udevadm control --reload-rules && udevadm trigger
#
# modified version of 60-libsane.rules from debian 9-10
ACTION!="add"             , GOTO="libsane_rules_end"
ENV{DEVTYPE}=="usb_device", GOTO="libsane_usb_rules_begin"
SUBSYSTEM=="usb_device"   , GOTO="libsane_usb_rules_begin"
SUBSYSTEM!="usb_device"   , GOTO="libsane_usb_rules_end"

LABEL="libsane_usb_rules_begin"

# Canon CanoScan LiDE 220
ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="190f", ENV{libsane_matched}="yes"

# The following rule will disable USB autosuspend for the device
ENV{DEVTYPE}=="usb_device", ENV{libsane_matched}=="yes", TEST=="power/control", ATTR{power/control}="on"

LABEL="libsane_usb_rules_end"

ENV{libsane_matched}=="yes", RUN+="/bin/setfacl -m g:scanner:rw $env{DEVNAME}"

LABEL="libsane_rules_end"

Source: debian wiki, std* fix