automate adding users with smbpasswd

  • kc0tma
  • o|||||||o
  • Web Master
  • User avatar
  • Posts: 3318
  • Loc: Trout Creek, MT

Post 3+ Months Ago

So I'm getting my new server going and right now I'm working on using smbpasswd to add approximately 287 users. I've got a file with all my usernames and their passwords, seperated by a space. Yesterday when I created their accounts with home directories and set their passwords I used a little perl script to do it and it worked splendidly. I'm not having as much luck with smbpasswd though.

So I think I need to do smbpasswd -as username. The -s option puts it in silent mode and reads the password I input from stdin and doesn't prompt for the password. But I just can't get the damn thing to work. How do I input the password with one shell command so that I can automate it instead of typing 287 passwords twice?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Don2007
  • Web Master
  • Web Master
  • Don2007
  • Posts: 4924
  • Loc: NY

Post 3+ Months Ago

I never used it but I took a quick look at it & it appears that it uses a config file, smb.conf. There is also a man page for smb.conf
  • kc0tma
  • o|||||||o
  • Web Master
  • User avatar
  • Posts: 3318
  • Loc: Trout Creek, MT

Post 3+ Months Ago

Actually I think I may have accidentally come up with a solution. In goofing around, I found that if I do echo "Password" > /dev/tty | smbpasswd -as username it seems to work. So I think what I will do is get that server on the network and see if I can access a smb share on it with a username created in that fashion.
  • Don2007
  • Web Master
  • Web Master
  • Don2007
  • Posts: 4924
  • Loc: NY

Post 3+ Months Ago

Well done. I never would have thought of that.
  • kc0tma
  • o|||||||o
  • Web Master
  • User avatar
  • Posts: 3318
  • Loc: Trout Creek, MT

Post 3+ Months Ago

The man page for smbpasswwd is totally ass backwards:

man smbpasswd wrote:
-s
This option causes smbpasswd to be silent (i.e. not issue prompts) and to read its old and new passwords from standard input, rather than from /dev/tty (like the passwd(1) program does). This option is to aid people writing scripts to drive smbpasswd


That is opposite from how I got it to work unless I'm reading it wrong. It seems to me like when you just type smbpasswd and you put in the old password then new password twice, you are putting it into stdin, but the man page there says otherwise. I don't really care though because I got all 287 passwords added a lot easier then typing each and every single one out one by one.
  • Don2007
  • Web Master
  • Web Master
  • Don2007
  • Posts: 4924
  • Loc: NY

Post 3+ Months Ago

I just looked at the man page again & it seems that Samba & related docs have jumped to one person after another over the years. That might explain why parts of it don't make sense.

Had you not found a way, I was going to mention the pw command. I don't know if it would help for smb but I've found that it's easier than add user.

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 65 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.