Operating System - HP-UX
1833017 Members
2346 Online
110048 Solutions
New Discussion

Change passwd in automatic form

 
Jorge Prado T
Contributor

Change passwd in automatic form


Hi,
As change the passwd to a group of accounts in automatic form?
S.O: HP-UX 11i

Thank in advance

Jorge Prado T
5 REPLIES 5
mirco_1
Valued Contributor

Re: Change passwd in automatic form

hy,

it's not possible with the shell because the passwd command in interactive, but you can write a C program that generate the password crypted and replace the /etc/passwd.

DM.
Mel Burslan
Honored Contributor

Re: Change passwd in automatic form

If you are going to set them all to the same password (very bad security practice by the way, If I were you I would avoid this like plague), change only one of them to obtain the encrypted password hash, then use this command in a script:

/usr/sam/lbin/usermod.sam -p "Dx3zsaXO3q22." username

where the string in the double quotes is your encrypted password.

This method works on both trusted and untrusted systems but keep in mind that it is not a supported way by hp and the usermod.sam module can go away in later releases of th HPUX. So use it with caution.
________________________________
UNIX because I majored in cryptology...
Rita C Workman
Honored Contributor

Re: Change passwd in automatic form

Like was said..not great as far as security issue. We had a situation where we had to immediately change the password of a certain group of users. Our criteria was to change only users who had CAPITAL Letters in their login ID and had the value that the password had expired (3...)
You'd have to adjust for your specific situation, but here are my old notes on this:

1. Take a dummy account and key in the new password to get the encrypted password...

Here's the basic script we tested with:

newpass=""
cat /etc/passwd | while read line #read /etc/passwd line by line
do
echo $line | grep -q '^[A-Z][A-Z]*:[^:]*,3\.\.\.:' #see if it matches the criteria
if [ $? -eq 0 ]
then #now replace old passwd for new passwd and print line
username=`echo $line | cut -d: -f1`
therest=`echo $line | cut -d: -f 3-`
echo $username:$newpass:$therest
else #print unmodified lines
echo $line
fi
done

Rgrds,
Rita
Thomas Moersch
Occasional Advisor

Re: Change passwd in automatic form

Try expect.
Here is a link:
http://hpux.connect.org.uk/hppd/hpux/Tcl/expect-5.43/
As far as I know it is the only scripting language that will allow you to script password changes.

Thomas
Doug O'Leary
Honored Contributor

Re: Change passwd in automatic form

Hey,

If you're familiar with perl, the expect moduleis an excellent solution for this as well. Probably not worth learning if this is the only time you'll ever have to do it; however, it does come in handy. All the power of expect with the syntax of perl. Can't be beat.

Doug

------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html