5

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?

1 Answer 1

6

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.

4
  • Do I have to URL-encode the \ separating the user name and the domain? So should I assume it must be domain%5Cbob or domain\bob?
    – Anaphory
    Commented Nov 15, 2019 at 11:26
  • No idea. try it and report back?
    – fledermaus
    Commented Nov 18, 2019 at 19:33
  • 1
    You can enter the domain like this: smb://DOMAIN\user:password@foo/bar without further encoding. Commented Dec 3, 2019 at 9:51
  • Useful detail: %20 is the hexadecimal code for the ASCII space. Other characters you may have to encode are the hash (# = %23) and percent itself (% = %25). Other characters can be found in ASCII tables, like this one: ascii-code.com
    – AstroFloyd
    Commented Mar 28 at 10:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .