System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Password expiry notification script

 
srsatya
Occasional Visitor

Password expiry notification script

Hi,

I am looking for password aging script which notify through email. O.S version is "HP-UX B.11.31 U ia64".
3 REPLIES

Re: Password expiry notification script

Steven E. Protter
Exalted Contributor

Re: Password expiry notification script

Shalom,

passwd -sa

Generates a pretty nice report.

You can also configure the system to notify users X number of days before expiration. See the man page for passwd for details.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
viswanathkishore
Occasional Visitor

Re: Password expiry notification script

Following is a crude one. It works on Solaris running nis+
It is set to run once each night via cron.

more check_passwd_expiration
#!/bin/sh

#rsj 01/16/2003
#this script is intended to be ran from a cron job.
#It will email user warnings when their passwd is getting
#close to expiration.

mail_msg()
{
rmail $1 << EOF
Subject: $2
From: kishore
$1 $2
EOF
}

NDAYS=`/usr/bin/perl -e 'printf("%d\n", time / (3600 * 24))'`
echo NDAYS = $NDAYS

for user in `niscat -M passwd.org_dir | awk -F: '{printf("%s:%s:%s:%s:%s:%s\n", $1, $2, $8, $9, $10, $11)}'`
do
#echo user = $user
name=`echo $user | cut -d: -f1`
passwd=`echo $user | cut -d: -f2`
lastchg=`echo $user | cut -d: -f3`
min=`echo $user | cut -d: -f4`
max=`echo $user | cut -d: -f5`
warn=`echo $user | cut -d: -f6`
if [ "$max" != -1 -a "$passwd" != "*LK*" ]; then
if [ "$max" = "" ]; then
echo "invalid value of max for $name"
max=-1
fi
if [ "$lastchg" = "" ]; then
echo "invalid value of lastchg for $name"
lastchg=0
fi
#echo info = $name:$lastchg:$min:$max:$warn:$delta
delta=`expr $NDAYS - $lastchg`
expire=`expr $max - $delta`
if [ $expire -le 0 ]; then
echo info = $name:$lastchg:$min:$max:$warn:$delta
echo " Warning your passwd has expired"
mail_msg $name "Your passwd has expired"
elif [ $expire -le $warn ]; then
echo info = $name:$lastchg:$min:$max:$warn:$delta
echo " Warning passwd will expire in $expire days"
mail_msg $name "Warning your passwd expires in $expire days"
fi
fi
#else
#echo no expire for $name:$lastchg:$min:$max:$warn
#fi
done