1834355 Members
2263 Online
110066 Solutions
New Discussion

Re: Password script

 
ajk_2
Advisor

Password script

Hi all,

I have a Unix system (OS 10.20 without the Trusted System. If don't want to use SAM for each user's password changing. Can I write a password script for all users which force them to change password at once? Thank you very much.

Best Regards
ajk
8 REPLIES 8
Sridhar Bhaskarla
Honored Contributor

Re: Password script

Hi,

Try "passwd -f login_name" this should force the user to change the password. Look at the man page of passwd command.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Sridhar Bhaskarla
Honored Contributor

Re: Password script

oops.. You asked for a script. Try this way.

#awk '{FS=":";print $1}' /etc/passwd > userlist
#vi userlist


#for USER in `cat userlist`
>do
>passwd -f $USER
>done

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Wilfred Chau_1
Respected Contributor

Re: Password script

cp /etc/passwd /etc/passwd.bak
cat /etc/passwd |awk -F: {print $1} |
while read i
do
passwd -d $i
passwd -f $i
done

note:
passwd -d : delete user passwd
passwd -f : expire user's passwd


Good luck.
ajk_2
Advisor

Re: Password script

Dear Sridhar Bhaskarla,

I did try your method, but it said "does not exist". Do you know why? Thanks

Best Regards
ajk
Mark Fenton
Esteemed Contributor

Re: Password script

Perhaps a slight adaptation of Sridhar's script to obviate the need to edit the list of users to remove pseudo users:

USERLIST=`grep "/home" /etc/passwd | awk -F: '{print $1}'`
for EACH in $USERLIST
do
passwd -f $EACH
done


Where "/home" is where user directories live...

hth

Mark
ajk_2
Advisor

Re: Password script

Dear all,

Your all information are very helpful.
Thank you very much!

Best Regards
ajk
ajk_3
New Member

Re: Password script

Hi all,

How are you? Long time no see.
This time, I am doing the password script again. I make the 'userlist' file and then run:

# for USER in 'cat userlist'
> do
> passwd -f $USER
> done

then it has the message:

Usage:
passwd [name]
passwd -r files [-F files] [name]
passwd -r files [-e [shell]] [-gh] [name]
passwd -r files -s [-a]
passwd -r files -s [name]
passwd -r files [-d|-l] [-f] [-n min] [-w warn] [-x max] name
passwd -r nis [-e [shell]] [-gh] [name]
passwd -r nisplus [-e [shell]] [-gh] [-D domain] [name]
passwd -r nisplus -s [-a]
passwd -r nisplus -s [-D domain] [name]
passwd -r nisplus [-l] [-f] [-n min] [-w warn] [-x max] [-D domain] [nam
e]
passwd -r dce [-e [shell]] [-gh] [name]
#


Do you guys know why? Thank you!

ajk
Michael Campbell
Trusted Contributor

Re: Password script

ajk

Are you using 'cat userlist' or `cat userlist`? The quotes could be your problem.

Regards

Michael