Operating System - Linux
1820096 Members
3588 Online
109608 Solutions
New Discussion юеВ

Check user password expiry information !

 
Chris Fung
Frequent Advisor

Check user password expiry information !

Hi all,

I would like to create a script to collect all the user accounts with their password expiry date.

This script will be executed on daily basis and generate a report for administrator to inform related account owners to login and change their password accordingly.

From my understanding. The expiry date in Unix is in terms of seconds and has a baseline set to 1-Jan-1970. We need to take care for the maximum password life password policy as well.

Any idea to creat the script ? Appreciated it if you could give me some samples.

Best Regards,

Chris,
3 REPLIES 3
Steven E. Protter
Exalted Contributor

Re: Check user password expiry information !


-S This will output a short information about the status of the
password for a given account. Available to root user only.


From the man page

passwd -S username

You may want to use it in combination with other options.

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
Jerome Henry
Honored Contributor

Re: Check user password expiry information !

As Stevens says, passwd -S gives you the information you need for each user. The first part indicates if the user account is locked (L), has no password (NP), or has a usable password (P). The second part gives the date of the last password change. The next four parts are the minimum age, maximum age, warning period, and inactivity period for the password.

Maybe could you loop a script searching for each number above 500 (if your user accounting starts from 500), and just calculating max age - last change and piping it to a .txt if it's less than the value you want...

Would it suit your needs ?

J
You can lean only on what resists you...
Chris Fung
Frequent Advisor

Re: Check user password expiry information !

Hi there,

Thanks for the inputs !!

Cheers,

Chris,