Secure Password Policies on Ubuntu 22.04 Explained

Secure password policies are essential for maintaining the security of your Ubuntu 22.04 system. They help protect against unauthorized access by...


0

Introduction

Secure password policies are essential for maintaining the security of your Ubuntu 22.04 system. They help protect against unauthorized access by enforcing strong authentication measures. This guide will walk you through configuring secure password policies on Ubuntu 22.04 to enhance system security. By implementing secure password policies, you can ensure that all users adhere to best practices for password creation and maintenance. The following sections will cover prerequisites and detailed steps to configure these policies effectively.

Prerequisites

Before you begin setting up secure password policies on Ubuntu 22.04, ensure that you meet the following requirements:

  • An Ubuntu 22.04 system with administrative access
  • Basic knowledge of command-line interface (CLI) usage
  • Familiarity with system configuration files.

Step 1: Install Required Packages

To configure secure password policies, you’ll need to install the libpam-pwquality package. This package provides tools to enforce password complexity. Begin by running the following commands to update your package lists and install the necessary package for managing password policies:

sudo apt update
sudo apt install libpam-pwquality

Step 2: Configure Password Quality

Next, edit the PAM (Pluggable Authentication Modules) configuration file to define password quality requirements. This file is located at /etc/pam.d/common-password. Use the following command to open the file:

sudo nano /etc/pam.d/common-password

Find the line that includes pam_pwquality.so and adjust parameters such as minlen, dcredit, and ucredit to specify the minimum password length and complexity.

Step 3: Set Minimum Password Length

Enforcing a minimum password length is critical for secure password policies. Set a reasonable length to ensure passwords are not easily guessed. Add the following parameter under the pam_pwquality.so line in the common-password file to enforce a minimum of 12 characters:

minlen=12

Step 4: Enforce Character Class Requirements

To enhance security, require a mix of character types in passwords. This includes digits, uppercase, and lowercase letters. Add these parameters to ensure that at least one uppercase letter and one digit are included in every password:

ucredit=-1
dcredit=-1

Step 5: Implement Password Expiry

Setting password expiry ensures users change their passwords regularly, minimizing the risk of compromise. Edit the /etc/login.defs file to configure password aging. Use the following command to open the file:

sudo nano /etc/login.defs

Locate and modify the PASS_MAX_DAYS and PASS_MIN_DAYS parameters to control the maximum and minimum number of days before a password must be changed.

Step 6: Lockout Policies for Failed Attempts

Implementing lockout policies can prevent brute-force attacks. This involves configuring the pam_tally2 module to lock accounts after a defined number of failed login attempts. Open the common-auth file with the following command:

sudo nano /etc/pam.d/common-auth

Add the following line to lock an account after 5 failed attempts, unlocking it after 15 minutes:

auth required pam_tally2.so deny=5 unlock_time=900

Step 7: Configure Password Reuse Policy

Prevent users from reusing old passwords by setting a remember parameter. This ensures that users must choose new, unique passwords. Edit the common-password file again:

password [success=1 default=ignore] pam_unix.so obscure use_authtok remember=5

This setting prevents the last 5 passwords from being reused.

Step 8: Auditing Password Changes

Use the praudit command to audit changes to the password file. This can help track unauthorized modifications. Run the following command to review the authentication log, allowing you to monitor changes and ensure compliance with secure password policies:

sudo praudit /var/log/auth.log

Step 9: Enforce Password History

Password history ensures that users cannot switch between a set of passwords. Configure this by editing the common-password file. A

By following these steps, you can effectively implement secure password policies on your Ubuntu 22.04 system, enhancing its overall security and protecting against unauthorized access.


Like it? Share with your friends!

0

What's Your Reaction?

hate hate
0
hate
confused confused
0
confused
fail fail
0
fail
fun fun
0
fun
geeky geeky
0
geeky
love love
0
love
lol lol
0
lol
omg omg
0
omg
win win
0
win
Anoop Patel