LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-17-2016, 04:16 AM   #1
tonj
Member
 
Registered: Sep 2008
Posts: 544

Rep: Reputation: 37
script to automate "smbpasswd -a user"


I've written a script that installs samba on a new centos 7 64 bit server but I want the script to give the password when setting up the samba user. I've been trawling google for ages and there are examples out there but I can't get any of them to work. Most require that you manually input the smb-password but I want my script to do it automatically.
At the moment my script section is
Code:
#!/bin/bash
(snip loads of install script>>
useradd <username>  # creates the unix user
<snip section that creates the user a/c passwd>
smbpasswd -a <username here>  # creates aamba user
here's where I always get the 'New SMB password:' prompt.

after 'smbpasswd -a <username here>' I've tried
Code:
(echo newpassword; echo confirmNewPassword) | smbpasswd -s
doesn't work, I also tried
Code:
(echo $pw; echo $pw ) | smbpasswd -s -a $user
doesn't work, along with many other lines that I've forgotten. What do I need after 'smbpasswd -a <username here>' to make this work? thanks for any help.

update: I did find this post here: but it's gives this output with two errors:
Code:
passwd: Authentication token manipulation error
Added user <username>
smbpasswd: option requires an argument -- 'w'
Added user <username>.

Last edited by tonj; 11-17-2016 at 04:33 AM.
 
Old 11-17-2016, 06:43 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 24,365

Rep: Reputation: 5456Reputation: 5456Reputation: 5456Reputation: 5456Reputation: 5456Reputation: 5456Reputation: 5456Reputation: 5456Reputation: 5456Reputation: 5456Reputation: 5456
Try using printf instead of echo

printf "$pw\$pw\n" | smbpasswd -a -s $user
 
Old 11-18-2016, 02:24 AM   #3
tonj
Member
 
Registered: Sep 2008
Posts: 544

Original Poster
Rep: Reputation: 37
thankyou michael I did solve it in the end, the script at the link above does in fact work on a clean centos 7 install, I deleted the '-w' in it and it seemed to go okay and the samba share worked.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 01:03 AM
[SOLVED] expect feature to automate login to target host and "sudo su - user" apss_evaluator Linux - Newbie 6 10-08-2015 02:53 AM
PostFix + ISPConfig mail return "unknown user" or "no such user here" Jacky444 Linux - Server 1 02-10-2010 04:21 PM
Sama problem with "smbpasswd" linuxy2 Linux - Server 5 03-05-2007 02:43 AM
Can't install "glibmm" library. "configure" script can't find "sigc++-2.0&q kornerr Linux - General 4 05-10-2005 02:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration