!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! A !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Step 1 => Create script
Note : login with root user on your terminal
#vim smbuser.sh
#!/bin/bash
for USER in nirmal test2 test3 test4 test5
do
useradd
-r -s /bin/false $USER
PASSINPUT=`echo $USER|cut -c1-3`123 (echo $PASSINPUT ; echo $PASSINPUT) | smbpasswd -s -a $USER
done
# Now save this script
Step 2 => Run script to create users
#chmod +x smbuser.sh
#./smbuser.sh
Added user test2.
Added user test3.
Added user test4.
Added user test5.
Note : This script will create user test1 test2 test3 test4 test5 and set first 3 character and 123 for there password .
For Example : nirmal user password is nir123 .
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!B!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if you have thousand of user the you can take input from file also follow below
step.
Step 1 => Create a file and write all samba user name in the file like below
format.
Note : login with root user on your terminal
#vim /root/user.txt
nirmal
test1
test2
test3
test4
#vim smbuser.sh
#!/bin/bash
for USER in `cat /root/user.txt`
do
useradd
-r -s /bin/false $USER
PASSINPUT=`echo $USER|cut -c1-3`123 (echo $PASSINPUT ; echo $PASSINPUT) | smbpasswd -s -a $USER
done
# Now save this script
Step 2 => Run script to create users
#chmod +x smbuser.sh
#./smbuser.sh
Added user test2.
Added user test3.
Added user test4.
Added user test5.
Note : This script will create user nirmal test2 test3 test4 test5 and set first 3 character and 123 for there password .
For Example : nirmal user password is nir123 .
hi
ReplyDeleteI like Your posts Very helpful for me
ReplyDeleteThanks
ReplyDeletehi, I have a little modification on this script, but it always appears prompt password. Is there something important that I miss?
ReplyDeletethis my modification
#!/bin/bash
for USER in `cat /data/master/user.txt`
do
samba-tool user create $USER
PASS=`echo $USER|cut -c1-3`tinG@123
(echo $PASS ; echo $PASS) | su - $USER
done
Hi , if I want to set password as name+123(not only first 3 of the user). How can we do this for adding samba users only not Linux.
ReplyDeletenice content
ReplyDelete