LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS
User Name
Password
CentOS This forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation.

Notices


Reply
  Search this Thread
Old 07-29-2014, 05:35 AM   #1
somnathndy
Member
 
Registered: May 2013
Posts: 31

Rep: Reputation: Disabled
Multipla User add in SAMBA


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.
Attached Thumbnails
Click image for larger version

Name:	s3.jpg
Views:	42
Size:	146.1 KB
ID:	15984  
Attached Files
File Type: txt SambaUseradd.sh.txt (646 Bytes, 41 views)
File Type: txt sambauseradd.txt (207 Bytes, 32 views)
 
Old 07-29-2014, 08:57 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,623

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by somnathndy View Post
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'.

Last edited by TB0ne; 07-29-2014 at 09:01 AM.
 
Old 08-01-2014, 12:55 PM   #3
TomFunke
LQ Newbie
 
Registered: Nov 2009
Location: Berlin, Germany
Distribution: CentOS, OpenBSD, Ubuntu, Feodora, LinuxMint, Android
Posts: 4

Rep: Reputation: 0
the ultimate scripts for adding users and changing passwords

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
Attached Files
File Type: txt smbaddnewusers.txt (5.8 KB, 53 views)
File Type: txt smbchangepwd.txt (3.6 KB, 31 views)
File Type: txt config.sample.cfg.txt (2.4 KB, 22 views)
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
i can't add a user to samba baronobeefdip Linux - Server 3 06-08-2010 10:27 PM
samba - add user script - User account does not exist itzamecwp Linux - Server 2 01-18-2007 10:52 PM
How to Add a Samba User JonBL Fedora 4 10-25-2006 05:35 PM
add samba user abdbaru Linux - Newbie 1 05-28-2006 11:04 PM
add SAMBA user ashley75 Linux - General 13 07-19-2005 05:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS

All times are GMT -5. The time now is 08:26 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