LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-08-2011, 02:10 AM   #1
ramecare
Member
 
Registered: Feb 2011
Posts: 179

Rep: Reputation: 0
Creating samba user using shell script


Hello,

can any one help me how to create Samba user using shell script
 
Old 04-08-2011, 03:00 AM   #2
neal_alexandrov
LQ Newbie
 
Registered: Apr 2011
Location: Russia
Distribution: CentOS, Ubuntu
Posts: 11

Rep: Reputation: 0
Hello Ramecare

Quote:
Here is a script i found .. it will solve out your problem for sure

*********************************
#!/bin/bash
#
# Ensure that root is running the script.
##
WHOAMI=`/usr/bin/whoami`
if [ $WHOAMI != "root" ]; then
echo "You must be root to add news users!"
exit 1
fi
#
clear
NEW_USERS="/root/names.txt"
echo "Enter password you want to set for all users:"
read SMBPASS
cat $NEW_USERS | while read USER; do
#adduser $USER `echo $SMBPASS`; `echo $SMBPASS` | passwd --stdin $USER > /dev/null
adduser $USER -p $SMBPASS
echo Added user $USER
smbpasswd -e $USER -w $SMBPASS > /dev/null
(echo $SMBPASS; echo $SMBPASS) | smbpasswd -as $USER
echo -e "$USER = $USER" >> /etc/samba/smbusers
done
*********************************

Here in this script, you will have to give name of the users in /root/names.txt file line by line.
For Ex:
********
user 1
user 2
user 3
********
Let me know if it helped....
 
Old 04-08-2011, 07:16 AM   #3
ramecare
Member
 
Registered: Feb 2011
Posts: 179

Original Poster
Rep: Reputation: 0
Its working ! Thank u very much
 
Old 04-08-2011, 10:28 AM   #4
neal_alexandrov
LQ Newbie
 
Registered: Apr 2011
Location: Russia
Distribution: CentOS, Ubuntu
Posts: 11

Rep: Reputation: 0
Quote:
Originally Posted by ramecare View Post
Its working ! Thank u very much

Welcome
 
  


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
need a shell script for creating report HariharanV Linux - Software 1 08-31-2010 08:19 AM
creating a user with no shell fredanthony Linux - Newbie 8 07-18-2006 10:28 AM
Help with creating a shell script windisch Programming 66 10-07-2005 07:26 AM
creating shell script that executes as root regardless of who runs the script? m3kgt Linux - General 13 06-04-2004 11:23 PM
creating a new user using shell only ? ( RH 9 ) CooLMaN Linux - General 4 04-04-2004 12:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:47 AM.

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