100 Days of DevOps, Day 2: Temporary User Setup with Expiry

Managing users is a basic task in DevOps. Not everyone needs permanent access. Sometimes, a developer or tester only needs access for a short time. In those cases, we can create temporary users. These users expire on a set date and remove the need for …


This content originally appeared on DEV Community and was authored by M. Oly Mahmud

Managing users is a basic task in DevOps. Not everyone needs permanent access. Sometimes, a developer or tester only needs access for a short time. In those cases, we can create temporary users. These users expire on a set date and remove the need for manual cleanup.

Why Temporary Users?

  • Security: old accounts close on time
  • Automation: no need to delete users later
  • Compliance: helps in audits
  • Clean system: fewer unused accounts

Step 1: Create a User with Expiry

We use useradd with the -e option.

sudo useradd -e 2026-01-28 mila
  • -e sets the expiry date
  • mila is the username

Step 2: Set a Password

We must add a password so the user can log in.

sudo passwd mila

It will ask us to type the password twice.

Step 3: Verify Expiry

We check the user details with:

sudo chage -l mila

Output will show:

Account expires : Jan 28, 2026

Quick One-Liner (Optional)

We can also do this in one command:

sudo useradd -e 2026-01-28 mila && echo "mila:DevOps@123" | sudo chpasswd

This creates the user, sets expiry, and adds a password in one go.

Conclusion

We learned how to create a temporary Linux user that expires automatically. This keeps our system secure and tidy with less manual work.

Key Takeaways:

  • useradd -e → set expiry date
  • passwd or chpasswd → add a password
  • chage -l → check expiry date


This content originally appeared on DEV Community and was authored by M. Oly Mahmud


Print Share Comment Cite Upload Translate Updates
APA

M. Oly Mahmud | Sciencx (2025-09-10T05:26:42+00:00) 100 Days of DevOps, Day 2: Temporary User Setup with Expiry. Retrieved from https://www.scien.cx/2025/09/10/100-days-of-devops-day-2-temporary-user-setup-with-expiry/

MLA
" » 100 Days of DevOps, Day 2: Temporary User Setup with Expiry." M. Oly Mahmud | Sciencx - Wednesday September 10, 2025, https://www.scien.cx/2025/09/10/100-days-of-devops-day-2-temporary-user-setup-with-expiry/
HARVARD
M. Oly Mahmud | Sciencx Wednesday September 10, 2025 » 100 Days of DevOps, Day 2: Temporary User Setup with Expiry., viewed ,<https://www.scien.cx/2025/09/10/100-days-of-devops-day-2-temporary-user-setup-with-expiry/>
VANCOUVER
M. Oly Mahmud | Sciencx - » 100 Days of DevOps, Day 2: Temporary User Setup with Expiry. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/09/10/100-days-of-devops-day-2-temporary-user-setup-with-expiry/
CHICAGO
" » 100 Days of DevOps, Day 2: Temporary User Setup with Expiry." M. Oly Mahmud | Sciencx - Accessed . https://www.scien.cx/2025/09/10/100-days-of-devops-day-2-temporary-user-setup-with-expiry/
IEEE
" » 100 Days of DevOps, Day 2: Temporary User Setup with Expiry." M. Oly Mahmud | Sciencx [Online]. Available: https://www.scien.cx/2025/09/10/100-days-of-devops-day-2-temporary-user-setup-with-expiry/. [Accessed: ]
rf:citation
» 100 Days of DevOps, Day 2: Temporary User Setup with Expiry | M. Oly Mahmud | Sciencx | https://www.scien.cx/2025/09/10/100-days-of-devops-day-2-temporary-user-setup-with-expiry/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.