Operating System - HP-UX
1830938 Members
1693 Online
110017 Solutions
New Discussion

Script to batch change user passwd on HPUX11

 
Romeo_Lou
Advisor

Script to batch change user passwd on HPUX11

Dear ,
I want to batch change users password on HPUX via script,
Does there any command or script to auto input for
Changing password for username
New password:
Re-enter new password:
?

5 REPLIES 5
Tom Geudens
Honored Contributor

Re: Script to batch change user passwd on HPUX11

Hi,
No, you can not do that in a script ... unless you use a tool like expect.
See http://hpux.cs.utah.edu/ to find this software.

Regards,
Tom
A life ? Cool ! Where can I download one of those from ?
Frank Slootweg
Honored Contributor

Re: Script to batch change user passwd on HPUX11

This user's profile seems to be corrupt. I think hir profile is
http://forums.itrc.hp.com/cm/UserProfile/1,,CA714030!1,00.html
but that has no user name.

User "CA714030",

Please try to fix your profile. If you can not, then contact me (frank_slootweg@hp.com) with details and I will try to get the right people involved.

[Please no points (or "N/A") for *this* response.]
John de Villiers
Frequent Advisor

Re: Script to batch change user passwd on HPUX11

If youre changing the password to the same password for all the users in question, then you can just change the password of one user and then copy the encrypted text in the passwd file to all the other users that you want to change.

Its a bit easier when you have a trusted system, in that each user has his own passwd file. Same story, get the encrypted version of the password out of the file of the user where you manually changed it, and then paste that into the password files of the users you want to change it to.

The encypted password can also be copied to other systems, as it doesnt look like the hostname makes up part of the decryption.

John
Nick Wickens
Respected Contributor

Re: Script to batch change user passwd on HPUX11

Would you not be better off batch expiring the passwords which you can do with passwd -f command then the users will be forced to change at next login or you can set your security setup in SAM to do this automatically.

It sounds a bit of a security risk to have the same password for many logins ?
Hats ? We don't need no stinkin' hats !!
Steve Post
Trusted Contributor

Re: Script to batch change user passwd on HPUX11

Are you modifying a pile of passwords once?
Are you using just normal passwords?
If both are yes, you could try this....

Search through the forums for encrypt.c and/or encrypt.pl. The purpose of this program is to return the encrypted version of the plain text password.

Copy the password file to a secure server.

Make another copy with JUST the lines you want to modify.

Cycle through each line replace the second field (ie password), with a newly generated password.

I had to add 4000 users to a text file in this way. And I did not want to do it by hand. So I made a password "factory" instead.
I had an import file with just "username password" in it (one user per line).
I compiled encrypt.c and renamed the new program "pw".

I ran....

exec 3while read LINE <&3
do
user=`echo $LINE | awk '// { print $1 }'`
pass=`echo $LINE | awk '// { print $2 }'`
pass2=`./pw $pass | awk -F: '// {pirnt $2}'`
echo "${user}:${pass2}"
done

Steve