Friday, September 12, 2025

How to Make a Linux User Password Never Expire: Step-by-Step Guide


Introduction:

Password expiry policies are important for security, but sometimes you need to keep certain Linux user accounts active without enforcing password changes. For instance, in administrative or automation accounts like user1, frequent password expiration can disrupt services. In this guide, we’ll show you how to make a Linux user password never expire.


Step 1: Check the Current Password Expiry

Use the chage command to see when a user’s password will expire:

sudo chage -l user1

Example output:

Last password change : Jul 03, 2025 Password expires : Sep 01, 2025 Password inactive : never Account expires : never Minimum number of days between password change : 1 Maximum number of days between password change : 60 Number of days of warning before password expires : 7


Here, the password is set to expire every 60 days.


Step 2: Make the Password Never Expire

Option 1: Using chage

sudo chage -M 99999 user1
  • -M 99999 sets the maximum days between password changes to effectively never expire.

Verify the change:

sudo chage -l user1

You should now see:

Password expires : never

Option 2: Using passwd

sudo passwd -x 99999 user1

Step 3: Verify the Configuration

Check again with:

sudo chage -l user1

Ensure:

  • Password expires: never

  • Account expires: never

This ensures the account will not require periodic password changes.


Step 4: Best Practices

  • Only disable password expiry for accounts that require uninterrupted access

  • Keep strong passwords or use SSH keys where possible.

  • Monitor accounts regularly to maintain security.


Conclusion

Preventing password expiration in Linux is simple using chage or passwd. By setting

odiuser or any critical account to never expire, you can avoid service disruptions

while maintaining control over other security policies.

No comments:

Post a Comment