Skip to Content

How to fix “WARNING: Your password has expired.” in Linux?

Sometimes when we ssh to Linux box, we get this error “WARNING: Your password has expired.” You must change your password now and login again! Changing password for user ocp. Changing password for ocp.”

What does “WARNING: Your password has expired.” mean?

That means the password for this account expired. We need to change the password. But it will expire in 90 days (default ) again.

How to fix Your password has expired?

We can change the password expires date to never with this command ” chage -m 0 -M 99999 -I -1 -E -1 accountname” then the password would never expire.

How to check the account status in Linux?

[root@xxx ~]# chage -l ocp
Last password change : Oct 27, 2020
Password expires : Jan 25, 2021
Password inactive : Feb 24, 2021
Account expires : never
Minimum number of days between password change : 7
Maximum number of days between password change : 90
Number of days of warning before password expires : 7

How to change the account password expire date in Linux?

[root@xxx ~]# chage -m 0 -M 99999 -I -1 -E -1 ocp

[root@xxx ~]# chage -l ocp
Last password change : Oct 27, 2020
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7

Understanding Chage Command Options

  • -m, –mindays MIN_DAYS A value of zero for this field indicates that the user may change his/her password at any time.
  • -M, –maxdays MAX_DAYS Set the maximum number of days during which a password is valid. When MAX_DAYS plus LAST_DAY is less than the current day, the user will be required to change his/her password before being able to use his/her account. This occurrence can be planned for in advance by use of the -W option, which provides the user with advance warning.
  • -I, –inactive INACTIVE Passing the number -1 as the INACTIVE will remove an account’s inactivity.
  • -E, –expiredate EXPIRE_DATE Passing the number -1 as the EXPIRE_DATE will remove an account expiration date.

 

3 ways to change user password expiration date in Linux