How To Set Up A Web configured Print Server On Ubuntu Server Using SWAT, CUPS, And SAMBA

This how-to describes the process of setting up an intranet based print server using Ubuntu server. By using CUPS SAMBA and SWAT the final product is a web based solution to a headless print server.

This How-to has been cobbled together from assorted other how-tos and forums by me after recording as best I could the method I used after googling the various problems I had along the way. It is primarily based on

http://ubuntuforums.org/showthread.php?t=310450

which is excellent but a little dated.

We will use PRINTSERVER for the name of the computer and USERNAME and PASSWORD where appropriate. Please use your own ones as necessary. While installing Ubuntu server select openssh and LAMP server using the space bar when requested (these parts can also be installed into an existing Ubuntu installation but that is outside the scope of this how-to). Ensure that the PRINTSERVER has access to the internet and is not locked out by your firewall or something silly (is it plugged into to your network?).

Once Ubuntu is installed and you have logged in you can  determine the local ip address that was issued by your network's DHCP server to your PRINTSERVER by typing
 ifconfig

The PRINTSERVER local ip is the number following the first instance of inet. eg inet addr:192.168.2.8 means that the local ip address is 192.168.2.8 (Note: it's not 127.0.0.1. That's your loopback address.) Now go to another computer on your network where you will carry out the remainder of the installation.

Download install and run your favorite tty client on the other computer on your network that you will use to communicate with your print server. I like putty from:

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Open an ssh session (port 22) to the local ip address of your print server and log in. Now install CUPS:

sudo apt-get install cupsys cupsys-client xinetd

Copy the cups settings and protect them:

sudo cp /etc/cups/cupsd.conf /etc/cups/cupsd.conf.original
sudo chmod a-w  /etc/cups/cupsd.conf.original

Edit the admin line of the conf file to your email address:

sudo nano /etc/cups/cupsd.conf

Modify /etc/cups/cupsd.conf and add the lines:

ServerAdmin [email protected]
DefaultEncryption Never
Browsing on
BrowseAllow all

By adding # at the start of the line comment out the lines:

#BrowseAllow @LOCAL
#BrowseAddress @LOCAL
#Browsing off

For the <Location /> blocks after the "Allow, deny" line add:

Allow All

Particularly the first three and the "Add printer" one eg:

<Location />
  Order allow,deny
  Allow All
</Location>

Add a line to allow access to the webserver remotely:

Listen 631

Comment out all the other lines containing 631. NB: This allows ANYONE who can reach the server on port 631 to make changes to your printers. You may want to write a more restrictive Listen line (google it up or read the manual). I'm behind a router/firewall so I wanted to make it nice and easy.

Restart cups:

sudo /etc/init.d/cups restart
sudo /etc/init.d/xinetd restart

You may also like to restart your server with sudo reboot but it isn't mandatory.

Create a cups user (make sure you use a username that is already a unix user, e.g. the user name you set up at the beginning).

lppasswd -a yourusername

Attach your printer to your Linux server.

You can now browse the CUPSserver using a web browser on port 631. Open a browser and go to (for example) http://PRINTSERVER:631.

If you can't attach to the web gui remotely you'll need to debug (sorry :( ). To debug your cups installation reedit your cupsd.conf and change the line:

LogLevel warn

to

LogLevel debug

Then your CUPS error log is probably at /var/log/cups/error_log and you can view it using the nano text editor (alt-T to clear it before you save).

Follow the web gui as best as you can to add your printer. You may need to download drivers but my HP driver was preinstalled and worked fine. You'll have to google up the Linux drivers or possibly the Linux ppd file for your printer. I didnt need to add the ppd file but it looks easy enough on the CUPS web interface.

Now to turn your ubuntu CUPS print server in a windows friendly SAMBA print server. Install samba and swat:

sudo apt-get install samba smbfs swat

Create a Samba user (make sure you use a username that is already a unix user, e.g. the user name you set up at the beginning).

sudo smbpasswd -a username

Add SWAT to the xinet configuration and save.

sudo nano -w /etc/xinetd.d/swat
# description: SAMBA SWAT
{
service swat
disable = no
socket_type = stream
protocol = tcp
#should use a more limited user here
user = root
wait = no
server = /usr/sbin/swat
}

Reload Xinetd with the new configuration.

sudo dpkg-reconfigure xinetd

Verify that SWAT is up and running.  If you don't get any response, start Googling.

sudo netstat -tap | grep swat

Open a browser and go to http://PRINTSERVER:901 where PRINTSERVER is the network name (or local ip) of the PRINTSERVER. Enter "root" as the user and use the password you entered for the samba user.

Go to globals and enter an appropriate name for the workgroup and set security to user (some posts say share but I prefer user as shared folders are easier for me this way).

Click commit changes.

You should be able to muck about with your printers in SWAT and they should be available to your Windows network.

Good luck and remember google is your friend. ;)

Share this page:

3 Comment(s)