Operating System - HP-UX
1836375 Members
2244 Online
110100 Solutions
New Discussion

script to Reset passwd for some particular user

 
jkumar
Advisor

script to Reset passwd for some particular user

script to Reset passwd for some particular user (i want to reset passwd for some 100 users for that i need a script)
5 REPLIES 5
D Block 2
Respected Contributor

Re: script to Reset passwd for some particular user

The best tool is using SAM.
Golf is a Good Walk Spoiled, Mark Twain.
Raj D.
Honored Contributor

Re: script to Reset passwd for some particular user

jkumar,

Check this out,

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1087589

Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Wouter Jagers
Honored Contributor

Re: script to Reset passwd for some particular user

You started this thread a couple of times, it seems ;-)

IF you are NOT on a trusted system, the encrypted passwords are in the passwd file, so you could try to edit a copy (repeat,a copy!) of the file. Quick and dirty thing I just glued together on my linux box:

for i in `cat userlist.txt`; do cat passwd.copy | sed -e "s/^\($i\):.*:\(.*:.*:.*:.*:.*$\)/\1:r4hRJr4GJ4CqE:\2/" > passwd.copy; done

--> userlist.txt contains the usernames to 'reset', one per line.
--> passwd.copy is a copy (!) of the passwd file.
--> r4hRJr4GJ4CqE is an encrypted password, obtained by changing one user's password and recording the encrypted string from the passwd file.

After running the command, all users which were in userlist.txt should have this same password entry in the passwd copy.

The command seems to do what I want on my linux box. If you want to try it, test it extensively on COPIES of the file, and check everything thoroughly.

Again, this could only work on a system which has its passwords in /etc/passwd (NOT on a trusted system).

DON'T try this blindly on your live system ! It might turn out not be a good idea just as well. Make a few test users first or something..

Oh yea, and don't hold me responsible should careless fiddling with your passwd file get you into trouble ;-)

Good luck !

Cheers


an engineer's aim in a discussion is not to persuade, but to clarify.
jkumar
Advisor

Re: script to Reset passwd for some particular user

I have excuted the script and working thx
Wouter Jagers
Honored Contributor

Re: script to Reset passwd for some particular user

Nice, glad it works =)

Care to assign some points to my answer, then ? I did spend some time on your problem, and I'm saving up for my first hat :-p

Cheers
an engineer's aim in a discussion is not to persuade, but to clarify.