Force a user to change password upon first login

This is how you can force a Redhat user to change his password upon first login on a Redhat 5 installation. This might work on other versions and distributions…

  1. First lock the account to prevent the user from logging in until the change has been made
  2. # usermod -L <username>
  3. Change the password expiration date to 0 to ensure the user changes the password during the next login attempt
  4. # chage -d 0 <username>
  5. To unlock the account after the change do the following:
  6. # usermod -U <username>