I recently added a bunch of users and gave them randomly generated passwords. We've since instructed them to change their passwords, but we suspect that a large number of them have not.
How can we expire the passwords of everyone who hasn't changed their password yet?
We're on Ubuntu 9.04 server using normal /etc/passwd authentication.
You can use the chage command to see the last time they changed their password, for example:
You can mix that with a loop and awk of the /etc/passwd file, might be a better way though. Maybe something like:
To expire the password set the expiration date to a date in the past:
To remove the expiration use -1:
Combine these with Kyle's script.
However, you can get your
user
anddate_change
using only one call toawk
:or
or
However,
awk
is unnecessary:The date the password was last changed is listed in /etc/shadow in the third field (coded as days since 1970/01/01).
You could then use the chage utiliy to enforce a password change after n days since the last change. But beware that this setting is persistent, it will expire the password every n days, so if you don't want that you will have to reset this in a second run, after the first change.
I really would like an option to enforce a password change upon first login, like MacOS and Windows offers.