smbpasswd script

162 views
Skip to first unread message

niraj vara

unread,
Jul 15, 2008, 3:45:55 AM7/15/08
to vglug

Dear ALL

                I want to add bulk user in samba, so want a script for smbpasswd, so if any body then pls sent it to me


I have tried the following but its only assign  the blank passwd.


           
echo -e "$password\n$password" | smbpasswd -s -a $user
echo -e "$password\n$password" > /tmp/pass
smbpasswd -s -a $user < /tmp/pass

--
Niraj M. Vara
Linux Administrator
Indian Institute of Management Ahmedabad
Mobile : 9898221954

"DON'T TELL ME THE SKY IS THE LIMIT, THERE ARE FOOTPRINTS ON THE MOON"

Kaushal Patel

unread,
Jul 15, 2008, 4:17:33 AM7/15/08
to VG...@googlegroups.com
Hi all

Here is the script which i created to create user as well add them as SMB and assign qouta.

#################################################3
#!/bin/bash
username=$1
password=$2
whoami=`whoami`
datecreated=`date`
# Ensure that root is running the script.

if [ $whoami != "root" ]; then
        clear
        echo "You must be root to add news users!"
        exit 1
else
        clear
        useradd -g 501 $username > /dev/null
        echo $password | passwd --stdin $username > /dev/null
        echo "User $username has been created successfully."
        (echo $password; echo $password) | smbpasswd -as $username > /dev/null
        setquota -u $username 4000000 5000000 0 0 -a /home /dev/null
        echo "User $username has been added as samba user successfully."
        echo $username $password $datecreated >> /var/log/usercreated
fi
###############################################

This script can use if you have lot of user. Just create a txt file with username and password and use SED or CUT with this script.

Regards,
Kaushal Patel

Ritesh

unread,
Jul 15, 2008, 5:12:53 AM7/15/08
to VGLUG
Hi,

Its a very nice script. Thanks Kaushal


Regards,
Ritesh

On Jul 15, 1:17 pm, "Kaushal Patel" <kaushalpatel1...@gmail.com>
wrote:
> > "DON'T TELL ME THE SKY IS THE LIMIT, THERE ARE FOOTPRINTS ON THE MOON"- Hide quoted text -
>
> - Show quoted text -

niraj vara

unread,
Jul 15, 2008, 5:54:16 AM7/15/08
to VG...@googlegroups.com

Dear

       Not work in RHEL-5, I do the same.

Kaushal Patel

unread,
Jul 15, 2008, 8:29:44 AM7/15/08
to VG...@googlegroups.com
I have CentOS 5. This script is working well on this machine. If you have RHEL 5 then it should work.

Let me know what error you received.

Regards,
Kaushal Patel

ElectroMech

unread,
Jul 16, 2008, 12:24:21 AM7/16/08
to VG...@googlegroups.com
Working fine for RHEL5.

Absolutely excellent.

you can user for loop to add bulk users with this script.
--

--
Nilesh Vaghela
ElectroMech
Redhat Channel Partner and Training Partner
16, Sun Rise complex,
Nr. Mansi cross Road,
Satellite Rd, Ahmedabad
25, The Emperor, Fatehgunj, Baroda.
www.electromech.info
Reply all
Reply to author
Forward
0 new messages