This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature

How to share a scanner on your network

By Manolis Tzanidakis on October 27, 2006 (8:00:00 AM)

Share    Print    Comments   

After hours of research and tweaking, all your computers are connected to each other and the Internet, and you can print your documents on a printer connected to another system -- but you still must take a break when someone else wants to use the scanner connected to your system. Save the money additional scanners would cost by sharing your scanner on your LAN.

Start with SANE (Scanning Access Now Easy), the scanning suite for Linux and other Unix-like systems. Check the project's list of supported devices. If your scanner is listed, most of the job is already done.

SANE consists of two packages, sane-backends and sane-frontends. The backends package includes scanner drivers and command-line interface (CLI) utilities for using the scanner. You'll want to install this package on both the server and the clients. The frontends package contains graphical and CLI-based front ends for the scanning process. We won't use this package, because we can use one of the more advanced front ends for SANE; more on that later.

Begin by installing the sane-backends package. Packages and ports are available for most Linux and BSD distributions. In Debian and Ubuntu the package is called sane-utils; Slackware and Arch simply name it sane. If you prefer building from source, it's a trivial ./configure; make; make install process. Documentation is provided in the source tarball. When the installation is done, check that your scanner is detected by running scanimage -L as root. The output of this command should look something like the following:

device `plustek:libusb:001:003' is a Epson Perfection 1260/Photo USB flatbed scanner

While you could run saned, the scanning daemon, as root, it's better to run it as a less privileged user, saned, instead, to improve security. If the saned user is not added by the package of your distribution, add it manually with the command:

if ! id saned; then groupadd saned; useradd -g saned -G scanner -s /bin/false -d /dev/null saned; fi

Add your non-root user to the scanner group with the command usermod -a -G username scanner.

If your Linux distribution uses UDEV for device node management -- as most modern distributions do -- you should reboot to ensure that the new udev rules for SANE are loaded and that you're able to scan as a non-root user. To verify that your system uses UDEV, check for the presence of the directory /dev/.udev and see whether the udevd process is running with the command ps aux | grep udevd. You can avoid rebooting and manually restart the udev daemon, but that's not very easy, so it's better to reboot. If your distribution uses static device nodes, take a look at SANE's README.linux file for more information on how to manually fix permissions and allow non-root users to access the scanner. Just to be sure that users other than root can access the scanner, run scanimage -L as the non-root user you previously added to the scanner group after you reboot; the output should be the same as before.

Now it's time to configure the saned daemon. Add the hostnames or IP addresses of the hosts you want to have access to the scanner to the file /etc/sane.d/saned.conf. If you want to provide access to all the computers on your network, just add your IP subnet -- for example, if your IP address is 192.168.1.1, your subnet is probably 192.168.1.0/24.

Check that a sane-port line exists in /etc/services, or add the following line if it's not:

sane-port 6566/tcp # SANE network scanner daemon

Saned does not run as a standalone daemon and thus needs inetd (or xinetd) to work. Add the following line in your /etc/inetd.conf:

sane-port stream tcp nowait saned.saned /usr/sbin/saned saned

Now ask inetd to reload that file with the command kill -HUP `cat /var/run/inetd.pid` or your distribution's init script. The saned man page includes instructions on how to use xinetd instead of inetd or tcp_wrappers for more advanced control of access to saned.

The server should now be ready -- time to configure the clients. Install the sane-backends (or sane-utils, or sane) package on the clients and add the hostname or IP address of the server in /etc/sane.d/net.conf. Running scanimage -L as root should return something like:

device `net:mars:plustek:libusb:001:003' is a Epson Perfection 1260/Photo USB flatbed scanner

(mars is the hostname of my scanner server.) Now add your non-root user to the scanner group, as before, and you're done.

From a security perspective this setup is wide open; anyone who can access the network could run denial-of-service attacks on your server or just start scans to drive you crazy. You should only share a scanner this way on a protected, firewalled local network.

There are lots of front ends for SANE for all major operating systems; have a look at the complete list in SANE's home page. I run XSane on my Linux and BSD desktops. If you use Windows on your clients I suggest using SaneTwain, since I've had the most successful results with it. I installed a scanner/printer server for a small business years ago and they still happily run SaneTwain on Windows 98 and XP clients without problems.

That's it, enjoy your new scanner server. You have one more reason to be proud of your home or small business network.

Share    Print    Comments   

Comments

on How to share a scanner on your network

Note: Comments are owned by the poster. We are not responsible for their content.

Scanner

Posted by: Anonymous Coward on October 28, 2006 12:30 AM
I'll probably never own a scanner. I consider scanners and printers to be useless...

#

Re:Scanner

Posted by: Anonymous Coward on October 28, 2006 12:10 PM
Why not? Anything that you can scan in is reproducible. You can manipulate the data however you want. It's not like printers cost much (though ink does). If you want to save paper (always a good thing!), then at the bare minimum, a scanner should do because then you can recycle all of your papers (read "reduce clutter around the house") and store everything on your computer.

#

Re:Scanner

Posted by: Anonymous Coward on October 29, 2006 02:11 AM
Me too. We're typical unix users who find it more useful a keyboard and a mouse than an ipod and a web cam.

#

Re:Scanner

Posted by: Anonymous Coward on October 29, 2006 03:14 AM
Indeed. I still have no iPod (or other portable media player) or webcam.

#

Re:Scanner

Posted by: Anonymous Coward on October 29, 2006 07:36 AM
because there are no webcam drivers available in your distro ??

apart from that, very good article! i will give this a try after setting up ubunte edgy.

#

Re:Scanner

Posted by: Anonymous Coward on October 30, 2006 12:29 AM
That's because you're either a kid or a grunt and don't have to deal with real business people.

#

Re:Scanner

Posted by: Anonymous Coward on October 30, 2006 05:19 PM
"I'll probably never own a scanner. I consider scanners and printers to be useless..."

I consider your comment useless

#

Re:Scanner

Posted by: Anonymous Coward on November 01, 2006 02:11 PM
Then you're an idiot.

#

sane-twain bridge

Posted by: Anonymous Coward on October 31, 2006 09:30 PM
For windows sharing of the scanner, this bridge is great:

<a href="http://sanetwain.ozuzo.net/" title="ozuzo.net">http://sanetwain.ozuzo.net/</a ozuzo.net>

I've used the saned scanner for years now, and it's a great way to share the scanner among workstations. Some of the above comments on why scanners aren't necessary are silly (electronic record for a faxed PO?). This article was good. Thanks.

#

Re:Fine article - doesn't work yet

Posted by: Anonymous Coward on December 09, 2006 06:30 AM
As the article says you also need to add the server name or ip in the file<nobr> <wbr></nobr>/etc/sane.d/net.conf ( on the client side).

Also, the article forgot one detail: the file<nobr> <wbr></nobr>/etc/sane.d/saned.conf must be edited on the server to allow the client IP.

For example, to allow all clients of my local network (192.168.1.*) I added the following line:

192.168.1.1/24

If that still does not work then start saned manually on the server side with debug enabled:


  saned -d

That should tell you if a connection attempt is made.


 

#

Re:Fine article - doesn't work yet

Posted by: Administrator on December 09, 2006 02:37 PM
Yes, did all you suggested..
I'm using xinetd to start saned.
I couldn't start saned -d without stopping xinetd.
Once I had saned -d started I could use kooka on the client once only, as saned is not a daemon..
I then started xinetd with a debug option and discovered that xinetd starts saned but saned does not stay running..
As I noticed that trying to start saned -d while xinetd was running saned could not bind to the address..
Getting closer..
Any hints??

#

Nice guide

Posted by: Anonymous Coward on January 22, 2007 12:10 PM
This guide looks very helpfull, I am trying it right now.
Bravo file!

#

Small error in the guide...

Posted by: Anonymous Coward on March 23, 2007 04:35 AM
... well, at least under Ubuntu, the command above intended to add the saned user to the scanner group is not correct. It should be


      usermod -a -G scanner username

and if you followed the guide and either had or created a user called saned, then username should really be saned.

If you get this wrong, everything appears to be OK initially, and you can even telnet to verify that inetd listens on the right port and saned logs to your system logs, but the saned user will not have access to the scanner hardware, and thus cannot even list the printers right.

-- Per (also known by username baekgaard at my home machine called b4net dot dk).

#

Fine article - doesn't work yet

Posted by: Administrator on November 01, 2006 02:06 AM
followed the steps. On the server I already had the scanner working so I added the xinetd stuff and checked the<nobr> <wbr></nobr>/etc/services file then setup the client.

As root on the client, scanimage -L gives no devices and respones so quick I don't think it goes out over the network..

Any ideas??

#

Scanners..

Posted by: Administrator on November 05, 2006 05:58 AM
Like someone said I dont think ill ever own a scanner but this seems like a good guide.

#

How to share a scanner on your network

Posted by: Anonymous [ip: 192.168.2.125] on September 03, 2007 10:37 PM
Excellent guide !, It worked flawlessly in my setup. I am using Debian etch

#

How to share a scanner on your network

Posted by: Anonymous [ip: 60.53.234.25] on November 11, 2007 03:11 AM
Woaho! Who needs to be able to think with people like you on the Intarweb? This is exactly what I needed for a HP OfficeJet on a Slackware server, and Ubuntu clients. If this also works on the XP clients here, I might even have to send you money. Maybe.

Great guide!

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya