Windows – Using cups to print to windows domain with password in a separate file

cifscupsprintingsambawindows

Every guide I've seen so far that explains how to print to a Windows print server from CUPS, indicates to put the username and password, in plain text, in the Device URI either in the web interface (localhost:631) or in the /etc/cups/printers.conf

smb://user:password@hostname/printer

The trouble is my password contains spaces and special characters. When I attempt this, I still get NT authentication failures when printing test pages. I can connect via smbclient:

smbclient -L //ourprintserver01 -Uourdomain\\myusername

I've tried to create a /etc/samba/printing.auth file with the correct username, password and domain in it, as I've seen in some tutorials, but this still doesn't allow cups to properly authenticate. Is there a way to tell CUPS to use this file, or keep the password, username and domain in some other file cups can use?

Best Answer

If you create the printer, either through the web ui or via lpadmin with a URL with the special characters % encoded like this:

lpadmin -p fake -v smb://bob:pass%20word@rice/BLAH -P /tmp/foo.ppd

then the password will be stored in the /etc/cups/printers.conf file (which is readable only by root) and will not be displayed in the web UI.

Be careful though as if you accidentally enter a malformed URL then the cups web-ui won't be able to figure out which bit is the password and it will be displayed.

Related Question