automate adding users with smbpasswd

  • kc0tma
  • o|||||||o
  • Web Master
  • User avatar
  • Joined: Jul 20, 2007
  • Posts: 3318
  • Loc: Trout Creek, MT
  • Status: Offline

Post March 5th, 2010, 8:12 am

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?
Like Mr Spork, I also write about my interest in alcoholic beverages.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post March 5th, 2010, 8:12 am

  • Don2007
  • Web Master
  • Web Master
  • No Avatar
  • Joined: Nov 21, 2006
  • Posts: 4924
  • Loc: NY
  • Status: Offline

Post March 5th, 2010, 10:38 am

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
How do you know when a politician is lying? His mouth is moving.
  • kc0tma
  • o|||||||o
  • Web Master
  • User avatar
  • Joined: Jul 20, 2007
  • Posts: 3318
  • Loc: Trout Creek, MT
  • Status: Offline

Post March 5th, 2010, 11:11 am

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.
Like Mr Spork, I also write about my interest in alcoholic beverages.
  • Don2007
  • Web Master
  • Web Master
  • No Avatar
  • Joined: Nov 21, 2006
  • Posts: 4924
  • Loc: NY
  • Status: Offline

Post March 5th, 2010, 2:57 pm

Well done. I never would have thought of that.
How do you know when a politician is lying? His mouth is moving.
  • kc0tma
  • o|||||||o
  • Web Master
  • User avatar
  • Joined: Jul 20, 2007
  • Posts: 3318
  • Loc: Trout Creek, MT
  • Status: Offline

Post March 8th, 2010, 8:28 am

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.
Like Mr Spork, I also write about my interest in alcoholic beverages.
  • Don2007
  • Web Master
  • Web Master
  • No Avatar
  • Joined: Nov 21, 2006
  • Posts: 4924
  • Loc: NY
  • Status: Offline

Post March 8th, 2010, 2:40 pm

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.
How do you know when a politician is lying? His mouth is moving.

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 129 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
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.