scripted (bash) password changes for Samba users...

By donmc, 27 June, 2014

I was excited to find this, so I am saving it here.

To change an smb passwd in a bash script:

echo -e "newpasswd\nnewpasswd" | (smbpasswd -s username)

And note the "\n" in there to push a newline between the two passwords...

For the unix (Linux) username:

echo -e "newpass\nnewpass" | (passwd --stdin username)