Re: Reset password of 50 users trusted system (1298 Views)
Reply
Super Advisor
zxcv
Posts: 226
Registered: ‎04-09-2010
Message 1 of 8 (1,380 Views)
Accepted Solution

Reset password of 50 users trusted system

Hi ,

 

We have hpux 11iv2 , trusted system , i need to reset password of 50 users , i.e same passwd for all 50 users.

Also it must force them to change their passwords at first login .

 

Do we have any script for this ??

Valued Contributor
RAJD1
Posts: 60
Registered: ‎10-09-2011
Message 2 of 8 (1,364 Views)

Re: Reset password of 50 users trusted system

[ Edited ]

Hi Zxcv,

You can try to do the above task with a for loop,

 

1. get the 50 user list from the password file and create a file that will have only the users name: (ex: 50_user_list.txt )

 

#---------------- Start Script -------

# Script for changing 50 users password , with same password.

for user in `cat 50_user_list.txt`

do

passwd $user   

done

 

# Forcing passowrd to change at next logon:

for user in `cat 50_user_list.txt`

do

passwd -f $user   

done

echo " Done.."

#---------------------------------- End Script ---------------------------

 

 

-While executing this script , writedown the password in the putty screen and select it with the mouse , so that it will be in the buffer, by pressing the right click it will be pasted when it will ask for a password.

-If you select the password from text screen with a carriage return, you dont even  need to press enter  , just press 50 times right click when prompted for password.

 

-

 

 

Hth

Acclaimed Contributor
Dennis Handly
Posts: 25,281
Registered: ‎03-06-2006
Message 3 of 8 (1,360 Views)

Re: Reset password of 50 users trusted system

To use a for-loop reading from a file, in a real shell you can do:

for user in $(< 50_user_list.txt); do

Super Advisor
zxcv
Posts: 226
Registered: ‎04-09-2010
Message 4 of 8 (1,356 Views)

Re: Reset password of 50 users trusted system

Hi guys,

 

Is there any option by means of which i can enter this hash value ( password )  in that script and i dont have to right click 50 times ?

Honored Contributor
Matti_Kurkela
Posts: 6,271
Registered: ‎12-02-2001
Message 5 of 8 (1,328 Views)

Re: Reset password of 50 users trusted system

For 11iv2 and older, this is undocumented by HP, but still a widely known procedure. (It was listed in HP-UX FAQ documents available in Internet more than 10 years ago.)

 

Find the hash value. For example, set the desired password to one user on one system, then read the hash value from the user's password file (/tcb/files/auth/<first letter of username>/<username>)

 

Then replace this line in RAJD1's script:

passwd $user

 

with this line:

/usr/sam/lbin/usermod.sam -p "<hashvalue>" $user

 Replace the string <hashvalue> with the actual hash value.

MK
Super Advisor
zxcv
Posts: 226
Registered: ‎04-09-2010
Message 6 of 8 (1,308 Views)

Re: Reset password of 50 users trusted system

Thnaks Matti

Valued Contributor
RAJD1
Posts: 60
Registered: ‎10-09-2011
Message 7 of 8 (1,302 Views)

Re: Reset password of 50 users trusted system

Correction: <in my first post> in the script

 

for user in 50_user_list.txt  -->

-->  should be -->   for user in `cat 50_user_list.txt`

 

 

Cheers,

Raj.

Acclaimed Contributor
Dennis Handly
Posts: 25,281
Registered: ‎03-06-2006
Message 8 of 8 (1,298 Views)

Re: Reset password of 50 users trusted system

>Correction: <in my first post> in the script

 

You can use the Post's Options > Edit Reply to change your post.

Also better to remove evil cat, as showed above.  :-)

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.