Sharing a USB or network scanner over a network with SANE.
SCANNER SERVER CLIENT +-----------------+ +------------------------+ +-----------------------------+ | Stand-alone | | libsane + sane-utils | | libsane | | or | USB | | cable/wireless | | | multifunctional |<----->| saned.conf: permitted |<-------------->| dll.conf: uncomment net | | device | | connections | | net.conf: server IP address | +-----------------+ +------------------------+ +-----------------------------+
This page is written principally in the context of a user with Debian 8 (jessie) or Debian 9 (stretch) installed. Both distributions have an init system (the first process started during booting of the computer and which governs its subsequent behaviour) based on systemd. On a machine with a scanner connected to a USB port (the server), SANE with systemd is socket activated. The saned daemon is started when a request is received on the server from a client and is stopped when the request is fulfilled. This forms the basis for a scanner shared by the server to serve up an image of a document to an application on a client.
SCANNER CLIENT +-----------------+ +--------------------------+ | Stand-alone | | libsane | | or | cable/wireless | | | multifunctional |<-------------->| Vendor-specific packages | | device | | | +-----------------+ +--------------------------+
A scanner which is network enabled with a cabled or wireless connection (a network scanner) is accessed with the help of libsane and one of its collection of backends. libsane interworks with the non-SANE, HP-provided hpaio backend. Other vendors also provide a means to access a network scanner but there is generally a non-free aspect to what they offer, so configuration of their devices is not treated on this page.
First ensure the scanner is detected and scanning works from the server as described on the Scanner wiki page.
Check that the contents of /etc/default/saned fit the system and that saned is in the scanner group. No changes need be made to this file for the vast majority of users. You should see this:
$ groups saned saned : saned scanner
Add the hostnames, IP addresses or IP subnets that are permitted to use local SANE devices on the server in /etc/sane.d/saned.conf. For example, you could allow the local network using the following configuration, which will vary according to your network configuration:
If necessary (look at systemctl status saned.socket), enable the systemd socket service:
$ sudo systemctl enable saned.socket Created symlink from /etc/systemd/system/sockets.target.wants/saned.socket to /lib/systemd/system/saned.socket. $ sudo systemctl start saned.socket $ sudo systemctl status saned.socket
- The server will now be sharing the USB connected scanner with other designated machines on the network.
It is essential to install libsane and, for testing the client's ability to see the network scanner, it is recommended to install sane-utils. Success in detecting the shared scanner with scanimage indicates probable success with other frontends.
Uncomment the net backend entry in /etc/sane.d/dll.conf.
Add the IP address/hostname of the sane server to /etc/sane.d/net.conf.
- If everything is working correctly you should get something like this:
% scanimage -L
device `net:192.168.0.100:plustek:libusb:002:006' is a Canon N670U/N676U/LiDE20 USB flatbed scanner
Note that the net backend is not for accessing arbitrary scanners over a network. It's intended use is for the server (which has a SANE-supported scanner) to be able to export that scanner to clients on the network via a single SANE-specific, manufacturer-agnostic protocol.
Make sure you can access the scanner locally on the server. scanimage -L should detect the scanner. If that fails, try sane-find-scanner. Run those as an ordinary user and also as the saned user (or root) with sudo-u saned scanimage -L. See also Scanner for more information on the local configuration.
Bear in mind that sane-find-scanner does a generic USB scan; success indicates a user has sufficient privileges to access the USB devices. On the other hand, a negative response to scanimage -L means that none of the SANE backends have knowledge of this model of scanner, so will not talk to it.
If the scanner works on the server but not remotely, make sure the service is running correctly. systemd should tell you this:
$ systemctl status saned.socket ● saned.socket - saned incoming socket Loaded: loaded (/lib/systemd/system/saned.socket; enabled) Active: active (listening) since Wed 2017-11-15 22:28:05 UTC; 1s ago Listen: [::]:6566 (Stream) Accepted: 0; Connected: 0 Nov 15 22:28:05 mafalda systemd: Listening on saned incoming socket.
You should also be able to ping the host configured:
$ ping -c1 mafalda PING mafalda.anarc.at (192.168.0.6) 56(84) bytes of data. 64 bytes from mafalda.anarc.at (192.168.0.6): icmp_seq=1 ttl=64 time=0.400 ms --- mafalda.anarc.at ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.400/0.400/0.400/0.000 ms
You can also try to connect directly to the scanner with:
If you have trouble connecting multiple computers to the server, systemctl status saned.socket might show:
saned.socket: Too many incoming connections (1), dropping connection.
This is a known bug in the systemd unit. For a workaround on jessie or stretch:
cp /lib/systemd/system/saned.socket /etc/systemd/system/saned.socket.
Edit and replace MaxConnections=1 with MaxConnections=64.
On stretch it is probably more convenient to do:
systemctl edit --full saned.socket.
Scanning with a Network HP all-in-one (aio)-1
To scan over the network from a scanner on an HP aio (one which is not connected by USB to a computer) you need only to install libsane-hpaio (without its recommended packages) and pass the URI of the scanner to the frontend. A non-free plugin might be required for the scanning function.
The format of the URI is:
This URI can be given directly to the frontend. It can also be provided automatically to the frontend if either a print queue with the hp:/... backend is set up or mDNS broadcasts for the scanner are done by the aio. Automatic discovery will happen via the print queue if both it and mDNS are available as discovery methods.
The IP address could be known from the way the aio's networking was set up; or it could be got from the aio's front panel or deduced from the output of
Each printer model supported by the installed verion of libsane-hpaio is listed in /usr/share/hplip/data/models/models.dat. Model names are enclosed in square brackets; like so, [envy_4500_series].
A frontend can be started with (for example):
Typing the URI each time can be avoided by exploring what your DE (Desktop Environment) or WM (Window Manager) offers for customising a command. For typing from a terminal you might find a simple alias sufficient.
An hplip installation pulls in libsane-hpaio as a dependency and hplip provides the utility hp-makeuri. It can be used instead of the previous technique for finding a URI. A needed plugin can also be installed with hp-plugin.
Scanning with a Network HP all-in-one (aio)-2
Many users will configure an HP aio machine with hplip or hplip-gui, which set up the printing side of the device with hp-setup. Scanning should now be automatically available, as explained by a user on sane-devel and by an hplipopensource troubleshooting page. Simply typing the name of a favourite frontend or clicking on a menu entry should be sufficient to run the application:
simple-scan xsane xscanimage
The URI to pass to the frontend is obtained from the printer URI by replacing hp:/... with hpaio:/....
Setting up a printer with other device URIs, socket://..., ipp://... etc, will not give this automatic discovery of a scanner URI.
Scanning with a Network HP all-in-one (aio)-3
SCANNER ClIENT +------------------+ +---------------+ | Stand-alone or | | libsane | | multifunctional | cable/wireless | | | AirPrint-enabled |<-------------->| libsane-hpaio | | device | mDNS packets-->| package | +---------------- -+ +---------------+
Recent HP aios (since 2010) will probably come with AirPrint. When activated on the aio the URI of the scanner is formed from the mDNS broadcasts of the aio in co-operation with /usr/share/hplip/data/models/models.dat. Without setting up the printing function of the aio the scanner should be detected by
and the frontend should automatically run after doing
xsane simple-scan xscanimage
update-inetd --enable sane-port