sunil
sunil

Reputation: 771

echo smbpasswd by --stdin doesn't work

I want to make creating a samba password automated but this command doesn't work:

echo "passwd"|smbpasswd -a -s $user

It shows this error:

Mismatch - password unchanged. Unable to get new password.

Could you please suggest any option to make my script automated?

Upvotes: 12

Views: 6509

Answers (2)

elbarna
elbarna

Reputation: 771

The printf solution above works perfect, but also echo -e works fine

echo -e "yourpass\nyourpass\n" |smbpasswd -a -s youruser

Upvotes: 1

Alex Martelli
Alex Martelli

Reputation: 882751

You need to repeat the password, "for confirmation" so to speak, so e.g.

printf "passwd\npasswd\n" | smbpasswd -a -s $user

should work.

Upvotes: 21

Related Questions