Operating System - HP-UX
1828317 Members
3902 Online
109976 Solutions
New Discussion

useradd script on trusted system

 
SOLVED
Go to solution
Rosli Ahmad
Frequent Advisor

useradd script on trusted system

Hi,
I need to create 200 users under a trusted system. Is there any script available for this. My biggest concern is the default password for each acct created, how do I capture those from the useradd script. To go thru SAM is just too time consuming.

Thanking you in advance.
Regards
3 REPLIES 3
malay boy
Trusted Contributor
Solution

Re: useradd script on trusted system

USER=$1
GROUP=$2
useradd -g $GROUP -d /users/$USER -s /usr/bin/ksh -m -k /etc/skel/$GROUP $USER
echo "\n\n$USER created and added to $GROUP\n"
AUTHNUM=`/usr/lbin/modprpw -x $USER|awk -F= '{print $2}'`
echo "\nAuthorization number for $USER is $AUTHNUM"
echo "Press return"
read ans
return

Try this.This is from :

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x72bcd06ed8c8d4118fef0090279cd0f9,00.html.

test it out work like charm.

regards
mB
There are three person in my team-Me ,myself and I.
malay boy
Trusted Contributor

Re: useradd script on trusted system

Word of coutious:

1) you need a skeleton directory called /etc/skel/{GROUPNAME} .

if you don't like this just remove the -k option.Or point it to default skel : /etc/skel.

to run :

./test.sh username1 group1

test.sh = file which contain the script.

this will prompt the initial password.

Need to run using root.

regards
mB

There are three person in my team-Me ,myself and I.
Rosli Ahmad
Frequent Advisor

Re: useradd script on trusted system

Thank you for the reply.
I've tried the script and found out that users' password expired even during 1st login. I checked the /etc/default/useradd and found out the last line was 'EXPIRE'. I then removed this entry and 1st login was fine.
Any idea how can I play aorund with the /etc/default/useradd, especially in setting the password expiration period for all the users.

Thank you.