To force a linux user to change their password on next login
sudo chage -d 0 USERNAME
USERNAME with the actual user login. The
-d option will set the
last time that the password was updated to the unix epoch (January 1, 1970)
which will automatically cause the password to expire.
The chage command changes the number of days between password changes and the date of the last password change. This information is used by the system to determine when a user must change his/her password.
-d, --lastday LAST_DAY Set the number of days since January 1st, 1970 when the password was last changed. The date may also be expressed in the format YYYY-MM-DD (or the format more commonly used in your area).
If you want to set a user’s password and expire it at the same time:
sudo passwd -e USERNAME
Note: not all versions of
passwd will have the
-e switch, but I have seen
it for sure on Ubuntu.