Redirected from page "sane.d tutorial"

Clear message

Introduction

  • This tutorial will guide you on how to setup and access a scanner shared over a network. This allows other devices to access the scanner, without having to have the scanner plugged directly into the computer.

Assumptions

A number of assumptions were made regarding this tutorial, that may need to be changed to fit your environment:

  • The network is 192.168.0.0/24.
  • The scanner works locally.
  • The scanner server (the machine the scanner is local to) is located at 192.168.0.15.
  • The scanner server is running Ubuntu.

How to share scanners using SANE daemon (saned)

  • The following step-by-step guide to setting up saned should work for the vast majority of scanners. If you need to add scanner specific information, please do so on the scanner's wiki page.

Step 1: Set up your scanner on SANE first

  • In order to make network scanning work, you first need to get SANE working with your scanner. If your scanner is a USB scanner do not proceed to step 2 until it is correctly scanning via USB. If your scanner is a network attached scanner, you need to get it working on your saned server before sharing it out on the network. See the Scanners page for help setting up and troubleshooting sane.

Step 2: Tell SANE to run as a server (saned)

systemd only

  • Execute at a terminal:

    sudo nano /etc/systemd/system/saned.socket

    and input exactly:

    # Defaults for the saned initscript, from sane-utils
    
    # To enable under systemd please read README.Debian
    # Set to yes to start saned under SysV
    RUN=no
    
    # Set to the user saned should run as
    RUN_AS_USER=saned
    
    [Unit]
    Description=saned incoming socket
    
    [Socket]
    ListenStream=6566
    Accept=yes
    MaxConnections=1
    
    [Install]
    WantedBy=sockets.target

    Execute at a terminal:

    sudo nano /etc/systemd/system/saned@.service

    and input exactly:

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

upstart only

  1. We need to edit the file /etc/default/saned to tell the computer to start the saned server. To do that, we will run the following command from a terminal:

    sudo nano /etc/default/saned
  2. Look for the section that reads:

    # Set to yes to start saned
    RUN=no
  3. Edit that so that it reads:

    # Set to yes to start saned
    RUN=yes
  4. Save, and close.

Step 3: Tell saned who to share with

  1. We need to edit the file /etc/sane.d/saned.conf to tell saned who to share with. To do that, we will run the following command from a terminal:

    sudo nano /etc/sane.d/saned.conf
  2. Look for the section that reads:

    ## Access list
  3. Assuming you don't need to control access to the scanner, we will add the line "192.168.0.0/24" (share with everyone on the local network) after "## Access list":

    ## Access list
    192.168.0.0/24
  4. Save the file and close.

Step 4: Clean up tasks

systemd only

  • Execute at a terminal:

    sudo systemctl enable saned.socket
    sudo systemctl start saned.socket
    systemctl status saned.socket

    This should result in something similar to:

    ● saned.socket - saned incoming socket
       Loaded: loaded (/etc/systemd/system/saned.socket; enabled; vendor preset: enabled)
       Active: active (listening) since Tue 2016-08-30 23:58:23 CDT; 10min ago
       Listen: 0.0.0.0:6566 (Stream)
     Accepted: 0; Connected: 0
    
    Aug 30 23:58:23 pc systemd[1]: Listening on saned incoming socket.

upstart only

  1. Restart the saned service to get the new configurations by running the following command in a terminal:

    sudo service saned restart
  2. For Ubuntu 12.04 only, you will need to tell the computer to start saned automatically when the computer boots up by running the following command in a terminal:

    sudo update-rc.d saned defaults
  3. Check to make sure the saned service is up and running:

    sudo service saned status

    It should return something along the lines of:

    saned start/running, process 804
    If it does not, see the section on troubleshooting.

Setup saned clients

  • Now that you have your server set up, its time to setup your clients.

Setup Linux clients

  1. We need to tell the client computer where to find the saned server we want to connect with. To do that, we have to edit the file /etc/sane.d/net.conf by running the following command:

    sudo nano /etc/sane.d/net.conf
  2. Find the line that reads:

    ## saned hosts
  3. After that line, you need to add a line with the address of the Ubuntu system we installed the server on. That line will look like this:

    ## saned hosts
    192.168.0.15
  4. Find the line that reads:

    # connect_timeout = 60

    and change it so that it reads:

    connect_timeout = 60
  5. Save the file and close.
  6. Open Simple Scan. It will take a few seconds for the auto-discovery to work, and then the scanner will populate in the menu. Alternatively, one may use XSane Image scanning program, either via the GUI menu, or from a terminal:

    xsane
    and you should see you scanner.

Setup Windows clients

  • By default, Windows cannot connect to a saned network scanner (ex. Windows 7, or Windows 8.1 using the built-in Scan app). This is because sane servers do not use the Microsoft Scan Service (WS-Scan) protocol, and vice-versa. However, several tools are available to allow Windows machines to use sane servers for scanner access. For example, in Windows one may download an installer via http://sanetwain.ozuzo.net/ (1.36 tested working in Windows 8.1 x64).

Setup Mac client

  • Twain-SANE is a bridge for the MAC platform (10.6, 10.7) that allows you to use a SANE shared scanner with any twain enabled Mac program. For more on this project, see http://www.ellert.se/twain-sane/. If you really need to, SANE front ends are available for these platforms.

Troubleshooting sane daemon with upstart

  • If your network scanner does not work, the following procedures may be of help. Try to follow these steps in order.

Make sure your scanner works locally

  • From the server that is sharing out the scanner, make sure you can scan. If it doesn't work locally, it won't work remotely.

Make sure the saned service is running

  • From the server sharing out saned, run the following command:

    sudo service saned status
    it should show the saned service as up and running.

Test if the server can reach its own saned on localhost

  • Instead of using the scanner directly, try and access it via the localhost interface. If this doesn't work, it won't work across the network. Due to a bug in udev, it may be necessary to add the saned user to the lp group with this command:

    sudo usermod -a -G lp saned
    and restart the saned service.

Export the scanner to localhost

  1. Edit the saned.conf file by running the following command:

    sudo nano /etc/sane.d/saned.conf
  2. Look for the section that reads:

    ## Access list

    and add the following lines:

    ## Access list
    localhost
    127.0.0.1
    Save the file and close.

Tell SANE to use localhost

  • From the command line, run the following command to open net.conf in gedit:

    sudo nano /etc/sane.d/net.conf

    Look for the section that reads:

    ## saned hosts

    We need to add a line to tell SANE to use localhost for a host:

    ## saned hosts
    localhost
    127.0.0.1

Test XSane

  • From the command line, run:

    xsane
    You should now see two copies of your scanner. Make sure both can actually scan.

Check using XSane and command line options

  • From the command line, run the command:

    xsane [driver]:net"192.168.0.15

    Assuming that your scanner uses the epson2 backend, the command would be:

    xsane epson2:net:192.168.0.15

Check the local connection with telnet

  • If the above procedure doesn't work, you need to make sure you can connect to the saned server with telnet. We also should log what happens. We can do that by running the following commands:

    sudo netstat -tulpn | egrep '(:6566|saned)' saned-test.log
    telnet localhost 6566

Manually check other configuration files (advanced)

  • There are a number of configuration files that may cause a problem. Please attempt all other solutions before going down this path (including asking for help).

/etc/services

  • For all backends, check to make sure the following service is present:

    sane-port       6566/tcp                # SANE Control Port

    For those backends that require it, check to make sure the following service is present:

    sane-port       6566/udp                # SANE Control Port

/etc/hosts.allow & /etc/hosts.deny

  • Try temporarily commenting out any entries in these files. If you can scan after doing this, then you will need to specifically add your host or hosts to the /etc/hosts.allow file. The following entry will give access to saned to the local network:

    saned  192.168.0.

Compiling Sane from GIT

  • If Sane has a bug, please first file a bug report following the instructions here. While waiting for a fix, one may compile sane from GIT.

Seeking further support

SaneDaemonTutorial (last edited 2019-06-24 03:32:02 by 5g3-steven-7tv)