This is the password aging script for aix just completed. So far tested and still testing on one of our aix server running 5.3.0.0. So anyway as you can see it is very similar to pwage-hpux-T the only difference on aix /etc/passwd file looks in this format. Also for this script to work you need to have "+email@domain.com" at the end of your description in /etc/passwd file or the script won't work.
while encrypted password and password lastupdate date(in seconds) is stored in /etc/security/password with tabs in this format.
Quote:
aixguy:
Quote:
password = xxxxxxxxxxxxxx
lastupdate = 1261286093
So we just need to find a way to grab the lastupdate field for that we can use command sed -n -e "/$i/"{n; n; p;}' , then from there find time from 1970 in seconds minus lastupdate get it in days subtract that with 90 day password aging policy to get the days to expiry then send email.
Quote:
for i in `cat /etc/passwd | grep \@ | sed 's/:/+/' | cut -d+ -f1`
do
LASTPWCHG=`sed -n -e "/$i/ {n; n; p;}" /etc/security/passwd | sed 's/ //g' | awk '{ print $3 }'`
DAYSEC=`echo "60*60*24" | bc`
DAWNOFTIME=`/usr/bin/perl -e 'print int(time)'`
SECSAGO=`echo "$DAWNOFTIME - $LASTPWCHG" | bc`
DAYSAGO=`echo $SECSAGO/$DAYSEC | bc`
MAXAGE=90
LEFTDAYS=`echo $MAXAGE - $DAYSAGO | bc`
echo $LEFTDAYS
#
#
if [[ "$LEFTDAYS" = 7 ]]
then
EMAILID=`cat /etc/passwd | grep $i | sed 's/:/+/g' | cut -d+ -f6`
echo "Your unix id $i will expire in $LEFTDAYS days" | mailx -s "`uname -n` Password aging Reminder" $EMAILID
fi
if [[ "$LEFTDAYS" = 3 ]]
then
EMAILID=`cat /etc/passwd | grep $i | sed 's/:/+/g' | cut -d+ -f6`
echo "Your unix id $i will expire in $LEFTDAYS days" | mailx -s "`uname -n` Password aging Reminder" $EMAILID
fi
if [[ "$LEFTDAYS" -lt 0 ]]
then
EMAILID=`cat /etc/passwd | grep $i | sed 's/:/+/g' | cut -d+ -f6`
echo "Please note that your unix id $i has aleaady expired" | mailx -s "`uname -n` Password aging Reminder" $EMAILID
fi
done
feel free to modify/tighten to your requirements. All comments are welcome.