LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How do I set a user password to expire on a specific date? (https://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-set-a-user-password-to-expire-on-a-specific-date-738116/)

Linuxwho? 07-06-2009 12:55 PM

How do I set a user password to expire on a specific date?
 
CMD line. Using Red Hat Ent Linux 5. Thanks in advance.

repo 07-06-2009 01:00 PM

ty the -e switch

from man useradd
Code:

-e, --expiredate EXPIRE_DATE
          The date on which the user account will be disabled. The date is specified in the format YYYY-MM-DD.

          If not specified, useradd will use the default expiry date specified by the EXPIRE variable in /etc/default/useradd, or an empty string (no expiry) by default.


sonnik 07-06-2009 01:04 PM

If the account already exists, try some of the passwd options...

Code:

man passwd
For example, you can run a cron job that runs (under root privs) "passwd -l username"...

This will lock until you (root) either deletes it or unlocks it. I'm assuming you want to lock the credentials out altogether on a set date.

Linuxwho? 07-06-2009 01:22 PM

Thanks for your answer but seems incorrect....

1. I looked there already and my man page states "E" not "e" but that's weird:

-E, --expiredate EXPIRE_DATE
Set the date or number of days since January 1, 1970 on which the userâs account will no longer be
accessible. The date may also be expressed in the format YYYY-MM-DD (or the format more commonly used in your area). A user whose account is locked must contact the system administrator before being ble
to use the system again.

2. I am not looking to expire the account. That command expires the account on a date not the password. I am trying to simply set the password expiration date. For example, if I set the -E it will only change the expiry date not the password expire date. See below:

"[root@101 etc]# chage -l ed
Last password change : Jun 24, 2009
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 23
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
[root@101 etc]#
----
[root@101 etc]# chage -E 2009-07-07 ed
[root@101 etc]# chage -l ed
Last password change : Jun 24, 2009
Password expires : never
Password inactive : never
Account expires : Jul 07, 2009
Minimum number of days between password change : 23
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
[root@101 etc]#"

repo 07-06-2009 01:30 PM

Take a look at chage
http://www.thegeekstuff.com/2009/04/...ion-and-aging/

Linuxwho? 07-06-2009 01:40 PM

Quote:

Originally Posted by repo (Post 3598760)

chage -M number-of-days username worked! It changes the "Maximum number of days between password change" but also the expiration date itself. TY for the link repo!!

p.s. The man pages are ok but geared more toward trial and error rather than being real specific. I am fighting with this myself sometimes when trial and error must be the autonomous solution,lol. Still it is much appreciated getting the help on here. Great site!


All times are GMT -5. The time now is 07:18 PM.