You may have noticed that I posted this HOWTO over a year ago. A lot of things have changed and there are other ways to accomplish printing from Windows to a CUPS/Samba server. Please note also that I can't really support or look after this HOWTO anymore (no time, no nerve). And finally note, despite all that, it still works when followed step by step. Problems may arise depending on your Windows clients, your ppd and typos or other (stupid) mistakes in command lines and config files.

Someone should write a better, more up to date HOWTO. Volunteers?

Version 1.2 (purely arbitrary version numbering -- I am sure some things are still missing, please send me any suggestions you have to improve this guide).

Added some troubleshooting tips to help with common problems when running cupsaddsmb.

Added a warning not to forget to create and use a user to access the printer from the Windows clients.

Added a warning about the Samba option guest only = yes. Don't use it!

Added a warning (right after the "The Printerserver" heading) about having a working domain name system setup or a working /etc/hosts file to have all hostnames resolve correctly.

Added problem description and workaround about /var/spool/samba not being accessible for Windows client users to print to the server (permission problem).

Added information about using pdbedit to add users and the Samba 3.x passdb backend tdbsam.

Added a possible solution for the dreaded NT_STATUS_BAD_NETWORK_NAME error some people seem to have encountered. See the section about configuring Samba for the [print$] share here in the guide.

Abstract
If all works the way it is supposed to, after following this guide you should have a printer on a Unix machine (which runs CUPS) which can be used by any other Unix machine (with CUPS) on the network PLUS any Windows NT/2000/XP box WITHOUT having to install printer drivers on each of the boxes manually.

What you need:

A printer (PS or non-PS, maybe not TOO new or fancy)

A working network (home/office/whatever) consisting of more than one machine (or following this guide wouldn't make much sense, would it?)

I see there are a few other guides for CUPS and/or Samba, please read them as well! They might tell you things I forgot to mention here. Also, read the very useful and well written Gentoo Printing Guide, as I don't cover kernel configuration issues and the like here.

The Printserver

First of all: be sure that all your hostnames resolve correctly. Either have a working domain name system running on your network or appropriate entries in your /etc/hosts file. cupsaddsmb often borks if hostnames don't point to the correct machines.

The printserver is any Unix machine that runs CUPS (I've set all this up on my FreeBSD machine and have a Gentoo Laptop and 2 Windows 2000 boxes using the printer, but it should make no difference---using a Gentoo machine as a server, a dozen RedHat boxes as clients and 42 Windows XP installations works the same way). For this guide I will use a Gentoo 1.4 machine named PrintServer (how original) and a HP DeskJet 930C printer. I have no experience with other printers, so you may need to adjust certain steps according to your needs.

The main Samba configuration file is smb.conf. In Gentoo it is located at /etc/samba/smb.conf. It is divided in sections indicated by [sectionname]. Comments are either `#' or `;'. I will only explain a few parameters for the defined sections/shares, not the trivial ones. Look at the man page for smb.conf or the installed smb.conf.example or the Samba Web site or any of the numerous Samba books available or or or...

Be advised (thanks to graybeard and numerodix): If you like to use Samba's guest account to do anything concerning printing from Windows clients: don't.

Don't set guest only = yes in the global section.

I don't know why exactly, but the guest account seems to cause problems when running cupsaddsmb and sometimes when trying to connect from Windows machines. See below, too, when we talk about cupsaddsmb and the problems that can arise. Use a dedicated printer user, like "printeruser" or "printer" or "printme" or whatever. It doesn't hurt and it will certainly protect you from a lot of problems.

If anyone knows why this is, or how this works/works not, please tell me.

Do not set anything else than security = user (it's the default) in your smb.conf. Only causes trouble and bears many security risks if set to share, server, whatever. Read up on the topic in the official Samba HOWTO collection.

The following section allows for the PS drivers for Windows clients to be uploaded when needed. See later in this document how this works.

Attention To avoid the dreaded NT_STATUS_BAD_NETWORK_NAME error it seems to be necessary to put the comment ("this path holds the driver structure") BEFORE or AFTER the line with path =/etc/samba/printer! Especially if you just cut'n'paste the stuff I wrote here (you shouldn't because it's always safer to write such things on your own, as can be seen here). If it is on the same line then Samba seeks for a share with the path "/etc/samba/printer # this path holds..." which of course cannot be found.

Thanks an effing lot to Dan Herrington who noticed that problem and told me about it!

The following creates a printer share so Windows clients can access the printer via Network Neighborhood or whatever.

You will most certainly have to create the directories manually (mkdir /etc/samba/printer, the spool directory and so on). That should be it for the minimum configuration for Samba to share the installed printer throughout the (Windows) network.

IMPORTANT: There seems to be a problem with the permissions of the Samba spool directory (at least on my and TriGuN's machines) as of (not exactly sure) Samba 3.0.3, which wouldn't let Windows clients print to the server, even when logged on an authenticated correctly.

To resolve this problem, I had to do a

Code:

# chmod 777 /var/spool/samba

Not exactly a solution but it worked. I am not sure whether the problem still exists in any newer (or older) Samba version, but that's how to get rid of it.

I recently saw that /var/spool/samba gets created with 777 permissions anyway, so the above IS a solution

Now we have to add at least two Samba users to be able to install the printer drivers and to allow users to connect to the printer. Note that both users have to exist in the system's /etc/passwd file.

Be advised: It is important to have a printer user which will be used when logging in from the clients. Using the guest account doesn't really seem to work very well, please don't forget that step!

Of course the printer user can be any vaild Samba user you have on your system. Just be sure to add them to the list of valid users in smb.conf.

Code:

# smbpasswd -a printer_username
# smbpasswd -a root

root needs to be added to allow adding the PS drivers for Windows clients, and printer_username will be used by Windows clients when logging into PrintServer to connect to the printer. The Samba passwords need not (should not) be the same as the system passwords in /etc/passwd.

New versions of Samba (3.0+) use a different passdb backend than Samba 2.x. Refer to this section of the official HOWTO collection to learn how to convert your smbpasswd backend to the new tdbsam.

After converting (or if you freshly installed Samba 3.x and did not update from 2.x) you should set passdb backend = tdbsam in your smb.conf's [global] section. It would be a good idea to restart Samba now.

Now you can add users to your Samba password database (again, those users must already exist in the UNIX password database /etc/passwd) using the pdbedit command.

Code:

# pdbedit -a -u printer_username
# pdbedit -a -u root

That's it.

The last step is to add Samba to the default runlevel:

Code:

# rc-update add samba default

Configuring CUPS

This is a little more complicated (not much). CUPS' main config file is /etc/cups/cupsd.conf. It's structure is similar to Apache's httpd.conf file, so many of you might find it familiar. I'll outline the directives that need to be changed:

LogLevel debug # only while isntalling and testing, should later be changed to 'info'

MaxClients 100 # I've had to set this to 1000000000 or so because some time back,
# there seemed to be a bug in CUPS' controlling of the web interface,
# making CUPS think a denial of service attack was in progress when
# I tried to configure a printer with the web interface. weird.

<Location />
Order Deny,Allow
Deny From All
Allow From 192.168.0.* # the addresses of your internel network
# eg 192.168.0.* will allow connections from any host on
# the 192.168.0.0 network. change to whatever suits you
</Location>

<Location /admin>
AuthType Basic
AuthClass System
Allow From 192.168.0.* # same as above, allow any host on the 192.168.0.0 network
# to connect and do administrative tasks after authenticating
Order Deny,Allow
Deny From All
</Location>

The next items that need changing are mime.convs und mime.types.

Code:

mime.convs:

# The following line is found at near the end of the file. Uncomment it.
application/octet-stream application/vnd.cups-raw 0 -

mime.types:

# Again near the end of the file.
application/octet-stream

The changes to mime.convs and mime.types are needed to make CUPS print Microsoft Office document files. Many people seem to need that

CUPS is started via

Code:

# /etc/init.d/cupsd start

Add it to the default runlevel via

Code:

# rc-update add cupsd default

Installing a printer for and with CUPS

First, hope that your printer is supported (many many many printers are). Then go to LinuxPrinting.Org to find and download the correct PPD file for your printer and CUPS. To do so, click the link Printer Listings to the left. Select your printers manufacturer and the model in the pulldown menu, eg HP and DeskJet 930C. Click "Show". On the page coming up click the "recommended driver" link after reading the various notes and information. Then fetch the PPD file from the next page, again after reading the notes and introductions there. You may have to select your printers manufacturer and model again. Reading the CUPS quickstart guide is also very helpful when working with CUPS.

Now you have a PPD file for your printer to work with CUPS. Very nice. Place it in /usr/share/cups/model. The PPD for the HP DeskJet 930C was named HP-DeskJet_930C-hpijs.ppd. You should now install the printer. This can be done via the CUPS web interface or via command line. The web interface is found at http://PrintServer:631 once CUPS is running. If you use the web interface you need to restart CUPS once you put the PPD file in /usr/share/cups/model. Issue

Code:

# /etc/init.d/cupsd restart

Using the command line is quicker and you have more control. The following

Be sure to have the name (-p) right (the name you set above during the Samba configuration!) and to put in the correct usb:/dev/usb/blah, parallel:/dev/lpt0 or whatever device you have the printer on.

If all worked you can access the printer now from the web interface. You should now be able to print a test page. If you aren't, you did something wrong or I forgot something Please correct me.

Installing the Windows printer drivers

Now that the printer should be working it is time to install the drivers for the Windows clients to work. Samba 2.2 introduced this functionality I think. Browsing to the print server in the Network Neighbourhood, right-clicking on the printershare and selecting "connect" downloads the appropriate drivers automagically to the connecting client, avoiding the hassle of manually installing printer drivers locally.

I don't know exactly which of the two are better, but AFAIK the Adobe PS drivers need to be extracted on a Windows System since it's in .exe format. Also the whole procedure of finding and copying the correct files is a bit more hassle. The CUPS drivers seem to support some options the Adobe drivers don't. But I might be wrong. If anyone knows the steps involved in this please add them or send me a note about it.

The information in the following paragraphs is out of date since the CUPS developers are working on a new version of these drivers. Doing so they have pulled the old ones from the site but you can still use them as described in the cupsaddsmb man page.

Here I'll use the CUPS drivers for Windows. The downloaded file is called cups-samba-5.0rc2.tar.gz (EDIT: the old version was cups-samba-1.1.19.tar.gz). Extract the files contained into a directory.

cups-samba.ss is a TAR archive containing three files:
cups5.hlp, cupsdrvr5.dll and cupsui5.dll. These are the actual driver files.

The script called cups-samba.install might work installing the drivers. Try it! It didn't work for me because under FreeBSD, almost everything which is not part of the base system is installed somewhere under the prefix /usr/local/. This seems not to be the case for most things you install under Linux. So if anything like this is the case, I'll go through this manually, just to be sure. Suppose your CUPS installation resides under /usr/local/share/cups/, and you want to install the drivers there. Do the following:

Now we'll use the script cupsaddsmb provided by the CUPS distribution. It's man page is an interesting read.

Code:

# cupsaddsmb -H PrintServer -U root -h PrintServer -v HPDeskJet930C

Instead of HPDeskJet930C you could also specify "-a", which will "export all known printers".

Be advised: The execution of this command often causes the most trouble. Reading through the posts in this thread, you'll see some errors, maybe you can solve the problems you might be having by carefully reading the suggested solutions and hints.

The hostname given as a parameter for -h and -H (PrintServer) often does not resolve correctly and doesn't identify the print server for CUPS/Samba interaction.

If an error like

Code:

Warning: No PPD file for printer "CUPS_PRINTER_NAME" - skipping!

occurs, the first thing you should do is substitute PrintServer with localhost and try it again.

The command fails with an NT_STATUS_UNSUCCESSFUL. This error message is quite common, but can be triggered by many problems. It's unfortunately not very helpful.

If you do have anything other than security = user (you have been warned above!) then put it away and never let it return! Always have security = user in your smb.conf unless you have a really sane reason no to. Thanks to numerodix!

This should install the correct driver directory structure under /etc/samba/printer. That would be /etc/samba/printer/W32X86/2/. The files contained should be the 3 driver files and the PPD file, renamed to YourPrinterName.ppd (the name which you gave the printer when installing it (see above).

to be sure CUPS and Samba get everything correctly. Check the log files and see if everything was OK.

The clients

Here we'll deal with what has to be done on the clients which will use PrintServer as their print server.

UNIX/Linux/BSD

Whatever you use, the only thing needed is CUPS. On Gentoo install it
by

Code:

# emerge cups
# /etc/init.d/cupsd start
# rc-update add cupsd default

Do the equivalent on any other UNIX/Linux/BSD client.

That should be it. Nothing else will be needed. Just point your web browser
to http://localhost:631 (on the CLIENT!) and you'll see that PrintServer broadcasts all available printers to all CUPS clients.

Whatever. Very convenient. I am not sure how to make a specific printer the default on the client (so using only "lpr foobar.whatever.ps" will print to HPDeskJet930C on PrintServer), so if anyone knows this, please post it below

You have to edit /etc/cups/client.conf and set the directive ServerName to your printserver. In the case of this guide that would be the following:

Code:

/etc/cups/client.conf:

ServerName PrintServer

That allows for just entering

Code:

lpr foobar.whatever.ps

which will print foorbar.whatever.ps directly to the print server. VERY conventient.

Setting the ServerName in client.conf seems to work well for only one printer, I don't know what would happen if PrintServer had 2 or more printers installed. So maybe there is still another way to set a client's default remote printer.

Also, when accessing http://localhost:631 on the client now, no printers seem to be "found" by the client-CUPS. I think this is to be expected when setting ServerName in client.conf,

/EDIT

Windows NT/2000/XP

That's just a bit of point-and-click. Browse to \\PrintServer and right click on the printer (HPDeskJet930C) and click connect. This will download the drivers to the Windows client and now every application (such as Word or Acrobat) will offer HPDeskJet930C as an available printer to print to. Blah

Done

Well that should be it. Although I may have forgotten something. If you found that guide useful or if anything didn't work the way it should, please post feedback and responses here, PM me or send them to daff at dword dot org.

Links and Resources

CUPS HomepageSamba HomepageLinuxPrinting dot OrgKurt Pfeifle's Samba Print HOWTO
Note that this HOWTO really covers ANYTHING and EVERYTHING I've written here, plus a LOT more concerning CUPS and Samba, and generally printing support on networks. A really interesting read, with lots and lots of details. Unfortunately, it doesn't seem to be very popular; I've only now discovered HOW detailed and useful it is. If I knew about it earlier I would have saved myself a lot of time and work and wouldn't have had to find out everything by myself...Then again, it's not been around very long, maybe that's why I knew not about it FreeBSD Diary's CUPS Topic

Troubleshooting
See this page from Kurt Pfeifle's "Printing Support in Samba 3.0" manual. Lots of useful tips there! Be sure to look this one up first, before posting questions and problems! Maybe the solution you're looking for is right there._________________Instead of asking why a piece of software is using 1970s technology,
start asking why software is ignoring 30 years of accumulated wisdom.

Last edited by daff on Mon Jan 10, 2005 2:31 am; edited 25 times in total

Thanks a lot, I'm gona try this, I was too lazy to do it before, now I have no more excuses, there's not too much work left to do _________________My opinion may have changed, but not the fact that I am right.

Please do so and tell me if everything works the way it should!_________________Instead of asking why a piece of software is using 1970s technology,
start asking why software is ignoring 30 years of accumulated wisdom.

What about having no print server, just a windows box (that i can see and login to on samba) with a usb printer (hp officejet v40) hooked up to it?_________________Think about your breathing.http://floam.sh.nu

As you can see when running cupsaddsmb, it asks for a root password. So I enter the pw and it stops with an error and asks again. So the second time I just hit return to see if it would go without it. It seems to have gotten a little farther but still is unable to make the remote directory.

? That NT_STATUS_LOGON_FAILURE thing usually means a wrong password or that a user doesn't exist (and therefore supplies a wrong password). The second time it seems to get farther is just a result of the first error, because it tries to add the printer drivers as an unprivileged, anonymous user (which, to my knowledge, doesn't and shouldn't work).

Also, have you added a section [Lexmark] to your smb.conf file? See the Configuring Samba section of my how-to.

Hope that helps a little._________________Instead of asking why a piece of software is using 1970s technology,
start asking why software is ignoring 30 years of accumulated wisdom.

What about having no print server, just a windows box (that i can see and login to on samba) with a usb printer (hp officejet v40) hooked up to it?

That's not the topic of my howto here I'm sure it's covered elsewhere though, I think I've seen a guide or two on this topic in the past. Anyway, that should be entirely possible. You might want to search the forum._________________Instead of asking why a piece of software is using 1970s technology,
start asking why software is ignoring 30 years of accumulated wisdom.

After having some troubles with the cups driver for windows, I decided to try the Adobe PostScript drivers for windows. They were a breeze to install. You just download the self-extracting executable, then run it on the Windows machine. It then displays the standard EULA, click accept and next. Then it asks if it is a local or network printer. Select network printer, and hit next. Type the location of your printer (mine was \\192.168.1.101\Epson). Then click next. Keep clicking next until the installation finishes. It was an absolute breeze. I'm just slightly disappointed that I couldn't get the CUPS drivers working. Oh well. Great How-To though. Thanks!_________________Rationality is the recognition of the fact that nothing can alter the truth and nothing can take precedence over that act of perceiving it.

That sounds cool! My experience was quite vice versa. Once I found the CUPS drivers (which wasn't SO easy, although they are on the CUPS web site) I just copied the 3 files plus the ppd-file CUPS uses into the correct directory and ran cupsaddsmb (but I described all that above in the guide). That's what I call a breeze On Linux the included install script should do just about everything for you. What were your problems with the CUPS drivers, anyway?

The Adobe drivers gave me a hard time finding the correct files, extracting them (after installing them locally I had to search through some weird folders in the WINNT directory, brrr) and renaming them (uppercase mostly). I also don't recall being able to install them directly from a Windows onto the print server. Maybe Adobe have changed the self extracting install file. I am going to try this out when I have time and add it to the guide. Thanks!_________________Instead of asking why a piece of software is using 1970s technology,
start asking why software is ignoring 30 years of accumulated wisdom.

Hm, from what I have seen, the Adobe drivers install in a way that Windows thinks of the remote network printer as a local (PostScript) one. Am I right when I think that these need to be installed on every Windows client there is, since I don't see any files getting copied to the print server?

That's somewhat quite the contrary from what I want to do, which is to install printer drivers only on the print server, and then have the Windows clients automatically download the drivers from there when accessing the printer via the Network Neighborhood, right-clicking on it and clicking "Connect".

Admittedly, it's really not MUCH work to do, since the installation really IS a breeze, but when you have to administer, say, 50 Windows clients on a network, things like that can become boring It also does not fit in the concept of the automagical driver download/upload which I am very fond of (I'd say that's the only thing I really like about Windows 2000/XP).

That's also why I had to mess around so much with finding the correct files (ADOBEPS5.DLL, ADOBEPS.HLP, etc and the like) and putting them into CUPS' drivers directory manually (/usr/share/cups/drivers/).

Please correct me if I'm wrong!_________________Instead of asking why a piece of software is using 1970s technology,
start asking why software is ignoring 30 years of accumulated wisdom.

I know it's not what you intended to do with the Adobe drivers, but I just couldn't get the CUPS drivers to work. I thought this would be the best place to explain how to install the Adobe drivers. I agree with you that the automatic driver download is the best way to do it, but I just couldn't get it to work. It never set up the proper drivers directory for windows. If you've seen that before, maybe I could abandon the Adobe drivers and try again with CUPS._________________Rationality is the recognition of the fact that nothing can alter the truth and nothing can take precedence over that act of perceiving it.

Well you could tell me what it is exactly that's not working. Please post the error messages, the cupsaddsmb commandline you're using and your [print$] section._________________Instead of asking why a piece of software is using 1970s technology,
start asking why software is ignoring 30 years of accumulated wisdom.

Sorry it's been so long since I replied. Nothing actually returned an error message. Mainly, Windows (2000) kept trying to install local drivers, instead of grabbing the drivers from the printserver. I have been able to fix it by manually copying the drivers where they're supposed to be on the server. Thanks for the great tutorial._________________Rationality is the recognition of the fact that nothing can alter the truth and nothing can take precedence over that act of perceiving it.

I'm hoping there is something real easy that I missed as I've spent the better part of two days+ trying to get printing to work on my new Gentoo box.

I've emerged Samba, CUPS, FooMatic and hpijs. I've downloaded the latest Windows drivers from the CUPS website and installed it. I've updated my smb.conf file as I was using an older method (lpd & lpr) on my old RedHat server from which I'm upgrading.

I've also removed the comment marks as indicated in some How-To's in the files mime.convs and mime.types.

I can print fine from the new server (Gentoo of course) but I cannot print from the windows clients. I've been manually installing the drivers as I've had trouble getting the auto-download driver to work. From any of my Windows Machines, they can see the printer on the samba server. They can even see when I do test prints from the server. But whenever I try to print from the Windows clients, nothing happens. No jobs go into the queue.

UPDATE. I have a suspicion my problem has to do with not being able to download the drivers. I grabbed the Adobe driver like someone else mentioned above. It installed and I was able to print. But with limited capabliity - only get the Generic Option and it doesn't do color.

I'll take another crack at it tomorrow. Hopefully someone will enlighten me.

I really don't know what to say other than it is working now. After work today I came back to work on this printing problem. The one thing I did before attacking the problem was to verify that the *.ppd file and the three cups files were in my /etc/samba/printer/W32X86 directory:

HP-DeskJet_970C-hpijs.ppd
cups5.hlp
cupsdrv5.dll
cupsui5.dll

The other thing I did was, using smbaddusr, added the account nobody. Think it already existed, as it prompted me for new password. So I put one in.

Just for grins and giggles I went to each of my Windows PCs. I was trying to see if there was an option to load the CUPS drivers. Didn't find one. But I did a test print and it worked. So I re-installed the printer on all three machines and they all can now print.

Well, the most important thing is that you got it working now I suppose You do have a share in your smb.conf with the same name of the printer you added in CUPS? I.e. [HPDeskJet970] for example?. Also, maybe cupsaddsmb didn't like the read only=yes option in your [print$] section (my [print$] section only has comment =, path = and write list =, and nothing else, that should be enough)? And third, I believe the 3 CUPS files and the .ppd file need to be (in your case) under /etc/samba/printer/W32X86/2/.

Could you tell what kind of error messages cupsaddsmb gave you, also what the exact command line was you used?

PS: I think the Windows clients get the printer drivers from the server whenever you do a right-click on the network printer (browsing to \\printserver, for example) and click "Connect" (only if the local copy of the drivers is different from the previously downloaded)._________________Instead of asking why a piece of software is using 1970s technology,
start asking why software is ignoring 30 years of accumulated wisdom.

That seems to be a more deeper-lying problem...is Samba really running and is it running without any problems? Maybe have a look at the log files. Or look below.

HoGiHung wrote:

Password for root required to access kiragentoo via SAMBA:

I keep putting in my password but I get that message over and over.

When I try to use cupsaddsmb, the syntax is as follows:

cupsaddsmb -H kiragentoo -U root -h kiragentoo -v HPDeskjet

I've tried with my user account and the nobody account. Neither work.

I'll go back and look at those other things you suggested. At them moment I'm now trying to figure out why the DHCP server isn't working.

Good luck

HoGiHung wrote:

Thanks,

Ho...

Well, cupsaddsmb should be run as root (the system user, UID 0) with the commandline you posted above which seems to be correct. Other than that...I don't know what the problem could be..._________________Instead of asking why a piece of software is using 1970s technology,
start asking why software is ignoring 30 years of accumulated wisdom.

"The CUPS printer drivers are preferred over the Adobe drivers since
they support page accounting, banner pages, and page labels on all
printers. However, currently only Windows NT, 2000, and XP are sup-
ported by the CUPS drivers, so you will also need to get the Adobe
driver to support Windows 95, 98, and Me clients."