Linux Level 1, Task 5: Managing Temporary User Accounts¶
Today's task was a practical exercise in a very important security principle: managing temporary access. My goal was to create a user account for a developer that would automatically expire on a specific date. This is a common requirement for contractors, auditors, or any user who only needs access for a limited time.
I learned how to use the useradd command with the --expiredate flag and, just as importantly, how to use the chage command to verify that the expiration date was set correctly.
The Task¶
My objective was to create a temporary user account on App Server 1. The specific requirements were:
- Create a user named rose.
- Set the account's expiration date to 2024-04-15.
My Solution¶
-
Connect to Server: I logged into App Server 1 (
ssh tony@stapp01). -
Create the User with Expiry: I used a single
useraddcommand with the--expiredateflag.sudo useradd rose --expiredate 2024-04-15 -
Verification: This was the crucial step. I used the
chage -lcommand to list the account aging information for the new user.The output clearly showed the expiration date I had set, confirming my success.sudo chage -l roseAccount expires : Apr 15, 2024
Key Concepts (The "What & Why")¶
- Temporary Access Management: It's a significant security risk to have old, unused accounts sitting on a server. Creating accounts with an automatic expiration date is the best practice for any non-permanent user. It automates the process of revoking access and reduces the chance of human error.
- The
--expiredateflag: This flag for theuseraddcommand sets a specific date on which the user account will be disabled. The user will no longer be able to log in after this date. It's important to note that this disables the account; it does not delete the user or their files. - The
chagecommand: Thechage(change age) utility is the primary tool for managing password and account expiration policies for users. The-l(list) flag is perfect for viewing the current settings for a user, which is how I verified my work.
Commands I Used¶
sudo useradd rose --expiredate 2024-04-15: The main command to create the userroseand set their account expiration date.sudo chage -l rose: My verification command. It lists the account aging details for the userrose, allowing me to confirm theAccount expiresdate was set correctly.