Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need script to reset all passwords 1

Status
Not open for further replies.

Tison

Programmer
May 12, 1999
216
CH
I am in need of a script to reset a select group of users passwords,BUT, it must not prompt for input.

eg
LST="fred john mary"
for nam in $LST
do
passwd $nam
done

It must not prompt for input but just reset the password so that the user gets prompted at next login.
 
Can you not just use

passwd -f $nam

in the script to achieve this goal? HTH.
 
No,,I need to reset the password , not the gecos.
 
From the man page:

-f Force the user to change password at the next
login by expiring the password for name.

Nothing to do with gecos.
 
In my version of AIX (4.3.3) the man page shows ;
-f Changes the user information accessed by the finger command. You can use th
flag to provide your full name in the /etc/passwd file.

If I run the command I get ;
# passwd -f sacsti
sacsti's current gecos:
"Steven Tison"
Change (yes) or (no)? >
 
Ah, comprende! Mine was from Solaris. Strange how such basic things vary isn't it? Sorry, don't think I can help.
 
.....unless this script posted by pmmicha in another thread (albeit Redhat) gives you any ideas:

------Begin-------

# PASSWORD CHANGE SCRIPT

#!/usr/bin/ksh -p

USER="$1"
CHKUSER=`/usr/bin/cat /etc/passwd|/usr/bin/grep "${USER}"`

if [ "${USER}" == "${CHKUSER}" ]
then
/usr/bin/passwd
echo "0" > /home/${USER}/flag
else
print "Invalid user name."
fi
#EOS


Setup the file flag in all of the user directories owned by root:sys or root:root with 644 permissions. Then in each users .profile setup this if statement:

if [ `/usr/bin/cat ~/flag` -eq 1 ]
then
/UPDPSWD.ksh USER_NAME_HERE # for instance
fi


Set UPDPSWD.ksh or whatever you will call this script up as 755 permissions owned by root:root or root:sys.


Now the user could obviously change the name in his/her .profile, but unless they knew that the user they modified this to had a flag = 1, then it wouldn't do them any good. More could be done obviously to ensure checks which I would add myself as well. If you trust your users enough, this should work for you otherwise I don't think it can be done with the Redhat passwd command.

-----End-------

HTH.
 
use "pwdadm -f ADMCHG username"
this shud change the flags of that user to ADMCHG in the /etc/security/passwd file.
when the user logs in next time, he will be prompted for new password.

hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top