Skip to content

Practice Exercise: Managing Passwords and User Authentication in Linux

Objectives

  • Learn the importance of strong password policies in Linux.
  • Understand how to manage user passwords securely.
  • Explore techniques for enhancing user authentication and system security.
  • Practice working with password-related commands in Linux.

Scenario

Effective password management and user authentication are crucial components of Linux system security. In this exercise, you will dive into the world of Linux passwords. You will learn how to set strong password policies, manage user passwords securely, and employ techniques to enhance user authentication and overall system security.

Tasks

Task 1: Managing User Passwords

  • Explore methods for managing user passwords in Linux.
  • Explain how passwords are stored and encrypted in the /etc/shadow file.
  • Demonstrate how to change a user's password using the passwd command.
  • Emphasize the importance of password privacy and confidentiality.
    [intern@intern-a1t-inf-lnx1 ~]$ passwd
    Changing password for intern.
    Current password:
    New password:
    Retype new password:
    passwd: password updated successfully
    

Task 2: Password Aging and Expiry

  • Discuss the concept of password aging and expiry.
  • Explain how password aging policies can enhance security.
  • Demonstrate how to set password aging parameters using the chage command.
  • Provide examples of configuring password expiration for user accounts.
    [intern@intern-a1t-inf-lnx1 ~]$ chage -l intern
    Last password change                    : Sep 20, 2023
    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
    
    [intern@intern-a1t-inf-lnx1 ~]$ sudo chage -E 2024-01-01 intern
    [intern@intern-a1t-inf-lnx1 ~]$ sudo chage -l intern
    Last password change                    : Sep 20, 2023
    Password expires                    : never
    Password inactive                   : never
    Account expires                     : Jan 01, 2024
    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
    
    [intern@intern-a1t-inf-lnx1 ~]$ sudo chage -m 100 intern
    [intern@intern-a1t-inf-lnx1 ~]$ sudo chage -l intern
    Last password change                    : Sep 20, 2023
    Password expires                    : never
    Password inactive                   : never
    Account expires                     : Jan 01, 2024
    Minimum number of days between password change      : 100
    Maximum number of days between password change      : 99999
    Number of days of warning before password expires   : 7
    
    [intern@intern-a1t-inf-lnx1 ~]$ sudo chage -M 365 intern
    [intern@intern-a1t-inf-lnx1 ~]$ sudo chage -l intern
    Last password change                    : Sep 20, 2023
    Password expires                    : Sep 19, 2024
    Password inactive                   : never
    Account expires                     : Jan 01, 2024
    Minimum number of days between password change      : 100
    Maximum number of days between password change      : 365
    Number of days of warning before password expires   : 7
    
    [intern@intern-a1t-inf-lnx1 ~]$ sudo chage -d 0 new_user
    [intern@intern-a1t-inf-lnx1 ~]$ sudo chage -l new_user
    Last password change                    : password must be changed
    Password expires                    : password must be changed
    Password inactive                   : password must be changed
    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
    

Conclusion:

Effective password management and user authentication are essential for maintaining Linux system security. In this exercise, you've learned about strong password policies, secure password management, password aging, and two-factor authentication. By implementing these practices and following security best practices, you can significantly enhance the security of your Linux systems and protect against unauthorized access.