Operating System - HP-UX
1851482 Members
2943 Online
104059 Solutions
New Discussion

Re: add 50 users/10 boxes

 
brian_31
Super Advisor

add 50 users/10 boxes

Team:

I have a task to add 50 users to 10 boxes, can anyone guide me with a script that can do this? these are hp-ux 11.11 boxes using the standard /etc/passwd file. Please give me a start..

Thanks

brian
4 REPLIES 4
James R. Ferguson
Acclaimed Contributor

Re: add 50 users/10 boxes

Hi Brian:

Use 'useradd'. You can easily build a script that makes the call. See:

http://docs.hp.com/en/B2355-60127/useradd.1M.html

Regards!

...JRF...
Pete Randall
Outstanding Contributor

Re: add 50 users/10 boxes

Do all the boxes have all the same users? If so, you can just change one and then propagate the /etc/passwd file to the others. Otherwise you will need to script it as James suggests.


Pete


Pete
Yang Qin_1
Honored Contributor

Re: add 50 users/10 boxes

The difficult part is to create 50 passwords for those users. If you have 50 users created on one server, it will be easier.

Let say you have these 50 users created and you take these 50 users information (uname, uid, gid, home_dir, shell ...) from /etc/passwd file and put them in a file call it userinfo

The script can be written like this:

#!usr/bin/ksh

while read line
do
uname=`echo $line|cut -d":" -f1`
pwd=`echo $line|cut -d":" -f2`
uid=`echo $line|cut -d":" -f3`
gid=`echo $line|cut -d":" -f4`
home=`echo $line|cut -d":" -f6`
shell=`echo $line|cut -d":" -f7`

/usr/sbin/user -u $uid -g $gid -d $home -s $shell -m $uname
/usr/sam/lbin/usermod.sam -p $pwd $uname
done < /path_to/userinfo

exit

If you want to create passwords for users you may use encrypt or perl crypt() function to create encrypted passwords because "usermod.sam" need to use encrypted password as input.


Yang

A. Clay Stephenson
Acclaimed Contributor

Re: add 50 users/10 boxes

You are getting up to the number of boxes and users where you are really asking the wrong question. The question is how can I add the users in one place and somehow all the boxes can "see" them. The answer is NIS, NIS+, and/or LDAP -- and that is where you should be devoting your efforts. The best answer these days is probably LDAP but if you are using traditional passwd files then you can probably live with the limited security that NIS provides; it's no worse than that of traditional passwd files and NIS is the much easier of the three to initially learn.
If it ain't broke, I can fix that.