RHCSA Rapid Track
Course update
An updated version of this course is available that uses a newer version of Red Hat Enterprise Linux in the lab environment. Therefore, the RHEL 9.0 version of the lab environment will retire on December 31, 2024. Please complete any work in this lab environment before it is removed on December 31, 2024. For the most up-to-date version of this course, we recommend moving to the RHEL 9.3 version.
In this exercise, you set password policies for several users.
Outcomes
Force a password change when the user logs in to the system for the first time.
Force a password change every 90 days.
Set the account to expire 180 days from the current day.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command prepares your environment and ensures that all required resources are available.
[student@workstation ~]$ lab start users-password
Instructions
From
workstation, open an SSH session as thestudentuser to theserveramachine.[student@workstation ~]$
ssh student@servera[student@servera ~]$On
servera, use theusermodcommand to lock and unlock theoperator1user.As the
studentuser, use administrative rights to lock theoperator1account.[student@servera ~]$
sudo usermod -L operator1[sudo] password for student:studentTry to log in as
operator1. This command should fail.[student@servera ~]$
su - operator1Password:redhatsu: Authentication failureUnlock the
operator1account.[student@servera ~]$
sudo usermod -U operator1Try to log in as
operator1again. This time, the command should succeed.[student@servera ~]$
su - operator1Password:redhat...output omitted... [operator1@servera ~]$Log out of the
operator1user shell to return to thestudentuser shell.[operator1@servera ~]$
exitlogout
Change the password policy for the
operator1user to require a new password every 90 days. Confirm that the password age is successfully set.Switch to the
rootuser.[student@servera ~]$
sudo -i[sudo] password for student:student[root@servera ~]#Set the maximum age of the
operator1user's password to 90 days.[root@servera ~]#
chage -M 90 operator1Verify that the
operator1user's password expires 90 days after it is changed.[root@servera ~]#
chage -l operator1Last password change : Mar 10, 2022 Password expires : Jun 10, 2022 Password inactive : never Account expires : never Minimum number of days between password change : 0Maximum number of days between password change : 90Number of days of warning before password expires : 7
Force a password change on the first login for the
operator1account.[root@servera ~]#
chage -d 0 operator1Exit as the
rootuser from theserveramachine.[root@servera ~]#
exitlogout [student@servera ~]$Log in as
operator1and change the password toforsooth123. After setting the password, return to thestudentuser's shell.Log in as
operator1and change the password toforsooth123when prompted.[student@servera ~]$
su - operator1Password:redhatYou are required to change your password immediately (administrator enforced) Current password:redhatNew password:forsooth123Retype new password:forsooth123...output omitted... [operator1@servera ~]$Exit the
operator1user's shell to return to thestudentuser and then switch to therootuser.[operator1@servera ~]$
exitlogout [student@servera ~]$sudo -i[sudo] password for student:student[root@servera ~]#
Set the
operator1account to expire 180 days from the current day.Determine a date 180 days in the future. Use the format
%Fwith thedatecommand to get the exact value. This returned date is an example; use the value on your system for the steps after this one.[root@servera ~]#
date -d "+180 days" +%F2022-09-06Set the account to expire on the date that is displayed in the preceding step. For example:
[root@servera ~]#
chage -E 2022-09-06 operator1Verify that the account expiry date is successfully set.
[root@servera ~]#
chage -l operator1Last password change : Mar 10, 2022 Password expires : Jun 10, 2022 Password inactive : neverAccount expires : Sep 06, 2022Minimum number of days between password change : 0 Maximum number of days between password change : 90 Number of days of warning before password expires : 7
Set the passwords to expire 180 days from the current date for all users. Use administrative rights to edit the configuration file.
Set
PASS_MAX_DAYSto180in/etc/login.defs. Use administrative rights when you open the file with the text editor. You can use thevim /etc/login.defscommand to perform this step....output omitted... # Password aging controls: # # PASS_MAX_DAYS Maximum number of days a password may be # used. # PASS_MIN_DAYS Minimum number of days allowed between # password changes. # PASS_MIN_LEN Minimum acceptable password length. # PASS_WARN_AGE Number of days warning given before a # password expires. #
PASS_MAX_DAYS 180PASS_MIN_DAYS 0 PASS_WARN_AGE 7 ...output omitted...Important
The default password and account expiry settings apply to new users but not to existing users.
Return to the
workstationsystem as thestudentuser.[root@servera ~]#
exitlogout [student@servera ~]$exitlogout Connection to servera closed. [student@workstation ~]$
This concludes the section.