Linux turn OFF password expiration / aging

I’ve spent a bit of time setting and resetting passwords. The following article from nixcraft shows us how to  set this to custom settings.

/etc/shadow stores actual password in encrypted format for user’s account with additional properties related to user password.

The password expiration information for a user is contained in the last 6 fields. Password expiration for a select user can be disabled by editing the /etc/shadow file

However I recommend using chage command. 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.

To list current aging type chage command as follows:

# chage -l username

Output:

Last password change : May 22, 2007

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

To disable password aging / expiration for user foo, type command as follows and set:

Minimum Password Age to 0

Maximum Password Age to 99999

Password Inactive to -1

Account Expiration Date to -1

Interactive mode command:

# chage username

OR

# chage -I -1 -m 0 -M 99999 -E -1 username

via Linux turn OFF password expiration / aging.

Creating accounts in linux

The quick way I’ve found to create accounts in linux is as follows;

groupadd (user admin group)
adduser (user) -G (user admin group) -s /bin/bash
echo "(password)" | passwd --stdin "(user)"

doing this on a single server is probably overkill and you could type it out in the time it takes to set it up and run, but if you’re working on an environment this save’s plenty of time over a bunch of servers.

Go to top
%d bloggers like this: