LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (http://www.linuxquestions.org/questions/linux-security-4/)
-   -   Getting password expiry for all accounts in a single command (http://www.linuxquestions.org/questions/linux-security-4/getting-password-expiry-for-all-accounts-in-a-single-command-184078/)

jdc2048 05-21-2004 07:30 AM

Getting password expiry for all accounts in a single command
 
I am hoping this will be an easy one for someone. I am trying to get a list of password expiry on all accounts on several linux servers. I have found things like "passwd -S <user>" and "chage -l <user>" but I want one that dumps the whole list of accounts from the server in one foul swoop instead of by account.

unSpawn 05-25-2004 03:09 PM

Write a script or shell function?

jdc2048 05-26-2004 08:14 AM

Yeah, my co-worker wound up writing some regex stuff to get what we wanted. This was a crunch thing and didn't have time for much shell scripting. For anyone interested in other flavors the following will output the password expiry stuff in a single-line per user output.

Code:

Solaris (as root);
passwd -as

AIX (as root);
lsuser -a expires minlen minage maxage maxexpired ALL

And for Linux I had to do this which dumps out multiple lines per user;
Code:

for i in `cat /etc/passwd | awk -F: '{print $1}'`; do echo "UserName:\t${i}"; chage -l $i;done
From there it is regex h3ll to get all of this formatted nice and manager friendly. Neither of the flavors looks the same as the other, so you wind up having to write 3 different functions to parse the output.


All times are GMT -5. The time now is 01:38 AM.