LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   CentOS (https://www.linuxquestions.org/questions/centos-111/)
-   -   Multipla User add in SAMBA (https://www.linuxquestions.org/questions/centos-111/multipla-user-add-in-samba-4175512590/)

somnathndy 07-29-2014 05:35 AM

Multipla User add in SAMBA
 
3 Attachment(s)
Hi,
I have installed RHEL 6.3. I have created around 200 users and their home directories through "newuser" command. I wanted the same directories should be available on windows so I have configured SAMBA on RHEL. Now the problem is adding 200 users through"smbpasswd" command one-by-one. I was looking here for a suitable script for the same and found one at http://www.linuxquestions.org/questi...-users-309812/. I copied the script by "homely" at the end of the above link. I tried to modify it as new RHEL users are not required as it is already created so I modified it(attached with this) but whatever I am doing it is giving different errors. I am adding all screen shots and final file.

It is beyond of my control - please help. I have to add the users with passwords into samba.

TB0ne 07-29-2014 08:57 AM

Quote:

Originally Posted by somnathndy (Post 5211254)
Hi,
I have installed RHEL 6.3. I have created around 200 users and their home directories through "newuser" command. I wanted the same directories should be available on windows so I have configured SAMBA on RHEL. Now the problem is adding 200 users through"smbpasswd" command one-by-one. I was looking here for a suitable script for the same and found one at http://www.linuxquestions.org/questi...-users-309812/. I copied the script by "homely" at the end of the above link. I tried to modify it as new RHEL users are not required as it is already created so I modified it(attached with this) but whatever I am doing it is giving different errors. I am adding all screen shots and final file.

It is beyond of my control - please help. I have to add the users with passwords into samba.

It is not 'beyond your control'...you just have to show some effort, and edit the script, which you haven't done correctly. You're getting very clear syntax errors, so you just need to fix them. Have you done/tried ANYTHING to fix the script..which someone else wrote and you edited.....other than ask people to write you a script in three other threads???

The errors are very clear: you have left the ^M's in it (from where you copied the script from another thread), which is causing some of your problems. Remove them, either with sed, or by re-typing the script manually. After that, any other problems can be dealt with one at a time...and you can reference any of the VERY easily-found shell scripting tutorials to help put this 'in your control'.

TomFunke 08-01-2014 12:55 PM

the ultimate scripts for adding users and changing passwords
 
3 Attachment(s)
hi folks,
long ago i made a script for adding mass of users and one for changing passwords.
The first (smbaddnewusers) creates users in BSD or linux (also CentOS with SeLinux security) and for samba,
also creates the specified home directory and adjust SeLinux attributes,
the second one (smbchangepwd) changes the passwords for specified users (also for samba).
Place all files in /root/data/scripts/ and chmod this directory to 700
You can change the user directories according your environment in scripts.

Until now i used these scripts for creating Thousands of users or changing passwords, both in OpenBSD and Linux.
First you need to create a text file with all parameters and place it in /root/data/scripts/conf.newusers.cfg (chmod 700).
You can do this in linux with LibreOffice (or OpenOffice) Calc (see examples in attachment)

sample config file for smbaddnewusers
Code:

# /root/data/scripts/conf.newusers.cfg
# first you have to create this new users file!
# you can do this under Unix with LibreOffice (OpenOffice) Calc and export as csv in UTF-8 with separator ";"
# see example conf.newusers.ods
# format of conf.newusers.cfg in /root/data/scripts (chmod 700)
# # first char # specifies a comment line
# #login1;pwd2;uid3;gid4;comment5;homedir6;shell7;groups8
# admin;secretpassword;500;500;unix admin;/home/admin;/usr/local/bin/bash;users,wheel,someothergroup
admin;securepassword;501;501;IT Administrator;/home/admin;/usr/local/bin/bash;users,wheel
tom;securepassword;502;502;Tom admin;/home/tom;/usr/local/bin/bash;users,wheel,group-it,group-pub,group-team,,group-db
dave;securepassword;503;503;Dave Thorn;/data/share/usr/home/dave;/sbin/nologin;users,group-pub,group-team,group-db
john;securepassword;504;504;John Deer;/data/share/usr/home/john;/sbin/nologin;users,group-pub,group-team
#

sample config file for smbchangepwd
Code:

# /root/data/scripts/conf.changepwd.cfg
# first you have to create this users file!
# you can do this under Unix with LibreOffice (OpenOffice) Calc and export as csv in UTF-8 with separator ";"
# see example conf.changepwd.ods
# format of conf.changepwd.cfg in /root/data/scripts (chmod 700)
# # first char # specifies a comment line
# #username;newpassword
admin;newsecretpassword
#

Attachments:
smbaddnewusers - bash script, so bash has to be installed!
smbchangepwd - bash script, so bash has to be installed!
conf.sample.cfg (1) - sample config file for creating users including their home directory
conf.sample.cfg (2) - sample config for changing unix and samba passwords

#
i can't upload following files, if you are interested, send me your email adress.
conf.newusers.ods - conf.newusers.cfg as LibrOffice file
conf.changepwd.ods - conf.changepwd.cfg as LibrOffice file


All times are GMT -5. The time now is 11:36 PM.