Linux disable password expired

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.
Читайте также:  Изменение имя компьютера astra linux

David is a Cloud & DevOps Enthusiast. He has years of experience as a Linux engineer. He had working experience in AMD, EMC. He likes Linux, Python, bash, and more. He is a technical blogger and a Software Engineer. He enjoys sharing his learning and contributing to open-source.

howtouselinux.com is dedicated to providing comprehensive information on using Linux.

We hope you find our site helpful and informative.

Источник

Turning off password expiration on Linux

I found that I need to edit /etc/shadow . How exactly do I need to edit the root line below, so that my Linux does not ask me to change the password on the each log in?

root@ubuntu:~# cat /etc/shadow root:$6$U.dnAQ2f$FV$/aF23Yn.sq1BYVjinlI9251nAarzqGKES18RxadV5bTakcfCNYAMljUwSaQZYV0r4MttHF0SFO7ebq3E1m/:0:0:99999:7. 
root:$6$U.dnAQ2f$FV$/aF23Yn.sq1BYVjinlI9251nAarzqGKES18RxadV5bTakcfCNYAMljUwSaQZYV0r4MttHF0SFO7ebq3E1m/:0:0. 

It stills asks for a password on log in. I also followed the instructions on http://www.lifelinux.com/setting-up-password-aging-in-linux/:

root@ubuntu:/home# chage -m 7 -M 60 -W 7 -I 7 root root@ubuntu:/home# chage -m 0 -M 99999 -I -1 root root@ubuntu:/home# change -l root -bash: change: command not found root@ubuntu:/home# chage -l root Last password change : password must be changed Password expires : password must be changed Password inactive : password must be changed 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 

What do I need to edit to remove password must be changed ? I also did chage -I -1 -m 0 -M 99999 -E -1 root , but it did not help.

1 Answer 1

describes the format of that file. Quoting from there, the fifth field is the maximum password age.

maximum password age The maximum password age is the number of days after which the user will have to change her password.

After this number of days is elapsed, the password may still be valid. The user should be asked to change her password the next time she will log in.

An empty field means that there are no maximum password age, no password warning period, and no password inactivity period (see below).

If the maximum password age is lower than the minimum password age, the user cannot change her password.

In your case, you’ve already hit the trigger, so you also need to get rid of the prompt to immediately change the password on the next login. Again consulting the man page.

date of last password change The date of the last password change, expressed as the number of days since Jan 1, 1970.

The value 0 has a special meaning, which is that the user should change her password the next time she will log in the system.

An empty field means that password aging features are disabled.

So you should also delete the zero from the third field. And once you’ve disabled that, there’s no need for the fourth one either.

Читайте также:  Антивирус линукс через терминал

So you should be able to delete the fifth field entirely to achieve what you want. As in

root:$6$U.dnAQ2f$FV$/aF23Yn.sq1BYVjinlI9251nAarzqGKES18RxadV5bTakcfCNYAMljUwSaQZYV0r4MttHF0SFO7ebq3E1m/. 

That said, I would generally advise against directly editing files like this unless you’re 100% sure you know what you’re doing.

Edit: Also, it appears that chage is part of the passwd package on Ubuntu, which I would have assumed you already had installed.

Источник

Linux: Set Password to NEVER Expire

If your Linux user’s password is about to expire, you may see a message as follows on your login screen:

Warning: Your password will expire in X days

In this note i will show how to disable the Linux user’s password expiration from the command line using the chage command.

Cool Tip: How to generate a password hash for /ect/shadow in Linux! Read more →

Set Password to NEVER Expire in Linux

To check a user’s password expiration settings in Linux, use the chage command:

$ chage -l - sample output - Last password change : Sep 30, 2021 Password expires : Dec 29, 2021 Password inactive : never Account expires : never Minimum number of days between password change : 0 Maximum number of days between password change : 90 Number of days of warning before password expires : 7

To set the Linux user’s password to never expire in an interactive mode:

$ sudo chage - sample output - Changing the aging information for Enter the new value, or press ENTER for the default Minimum Password Age [0]: Enter Maximum Password Age [90]: 99999 Last Password Change (YYYY-MM-DD) [2021-09-30]: Enter Password Expiration Warning [7]: Enter Password Inactive [-1]: Enter Account Expiration Date (YYYY-MM-DD) [-1]: Enter 

To turn off the Linux user’s password expiration non-interactively:

$ sudo chage -I -1 -m 0 -M 99999 -E -1

Ensure that the user’s password expiration settings have changed:

$ chage -l - sample output - Last password change : Sep 30, 2021 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

Cool Tip: Generate a random password from the Linux command line! Read more →

Читайте также:  Unifi controller linux mint

Источник

Non-Expiring password on Linux server

I’d like to set up an account on a linux server and make the account’s password never expire. I’m having difficulties figuring it out with the passwd man page. Could someone please help me out?

7 Answers 7

To maximize password expiration:

To disable account expiration:

To set the system defaults, look at /etc/default/useradd

Solaris/SunOS:

Turn off aging while allowing user to retain current password

Force user to change password at next login, and then turn off aging

(Hopefully this helps someone out)

You want the chage command you just set the account minimum password to a rediculously long time like 9999999999 days.

The complete command to mitigate any other previous configurations is the following:

chage -E -1 -M -1 -I -1 username 

AIX: Non expiring password

Changing user history size

change the users password

Clear flags that tells the OS to reset password on login (after password reset)

If you do not want to cause any commotion by editing your user history size you can use the following command to change the security file to say that the last time you reset your password is always today’s date. You can export this in your .profile file so it runs every time you log in as well.

chsec -f /etc/security/passwd -s -a lastupdate=`date +%s` 

Here is a full example of chage command (Change age) about Linux expiration password: Completely disable password expiration and account:

-m 0 : Minimum number of days for the password change. -M 99999 : Maximum number of days a password change. -I -1 : We set: "Password inactive" never. -E -1 : We set: "Expires Account" never. 

The example username is: sysadmit

[root@linux1~] # chage -m 0 -M 99999 -I -1 -1 -E sysadmit [root@linux1~] # chage --list sysadmit Last password change: July 15, 2017 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 Expires password 7 

Источник

Оцените статью
Adblock
detector