Forum Discussion
Periodic Password Change
I wouldn't recommend having it automatically change the password but you can setup an email alert that runs in cron that will calculate the days between today and the last password change and email if it is greater than say "90 days" so you can login and change the passwords.
In the SSH bash shell you can use 'chage -l' to view the last time the password was change.. for example
[root@hostname:Active:Standalone] config chage -l root | grep "Last password change"
Last password change : Apr 30, 2013
[root@hostname:Active:Standalone] config chage -l admin | grep "Last password change"
Last password change : Apr 30, 2013
[root@hostname:Active:Standalone] config
You can also look in the /etc/shadow file...
[root@hostname:Active:Standalone] config cat /etc/shadow | egrep "root|admin"
root:encrypted_password:15825:0:99999:7:::
admin:encrypted_password:15825:0:99999:7:::
[root@hostname:Active:Standalone] config
The third value is the days since 1/1/1970 that the password was changed. so for example on my system the number is 15825. Now you can get today's date in the same format by the following.
[root@hostname:Active:Standalone] config echo $(($(date +%s) / 60 / 60 / 24))
15936
[root@hostname:Active:Standalone] config
Now you can do some simple math...
[root@hostname:Active:Standalone] config echo $((15936-15825))
111
[root@hostname:Active:Standalone] config
So put all this together in a shell script and if the last value is greater than 90 (or whatever date you choose) then you can email an alert. You would want to do this for both the admin and the root users.
If you need help writing a script please let me know...
Seth Cooper
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com