[Samba] Re: smbpasswd usage

Mark Nienberg gmane at tippingmar.com
Sun Dec 25 05:32:56 GMT 2005

Michel Bouchet wrote:
> Hi,
> I used to set up Samba password on the command line with smbpasswd using the
> following syntax :
> smbpasswd -a newuser "usersecretpasswd"
> smbpasswd -e newuser
> but it does work any more.
> How can I do the same without having to type in the password ?
> Thanks in advance.
> Michel
I haven't tried it, but this messagage was in the archives from June 27,

I had a little bit of trouble on my Redhat 9 system trying to get
smbpasswd to accept passwords on stdin so I can script it.

All of the solutions I saw on the mailing list were of the general

(echo <pass>; echo <pass>) | smbpasswd -s <username>

For whatever reason, that didn't work for me.  (note: I'm not much of a
Bash programmer!)  What did however, is:

echo -n -e "$PASS1\n$PASS2" | smbpasswd -as $USERNAME

The -n switch tells echo not to add a trailing newline character, and
the -e switch tells it to interpret C-style escape characters, of which
\n is the carriage-return escape code.  This is also assuming $PASS1 is
identical to $PASS2.

Hope this helps someone!
-- Nick Soracco <nick at hrd-aerosystems.com> HRD Aerosystems, Inc.

More information about the samba mailing list