USD ($)
$
United States Dollar
Euro Member Countries
India Rupee
د.إ
United Arab Emirates dirham
ر.س
Saudi Arabia Riyal

Authentication and Authorization

Lesson 23/40 | Study Time: 20 Min

Authentication and authorization are fundamental to securing Linux systems by verifying user identities and controlling their access to resources. Authentication ensures users prove they are who they claim to be, commonly via passwords or multi-factor mechanisms, while authorization defines what actions authenticated users can perform.

Effective management includes enforcing strong password policies, safeguarding sensitive data with shadow files, configuring sudo privileges and auditing, and leveraging Pluggable Authentication Modules (PAM) for modular, flexible authentication frameworks. Multi-factor authentication further strengthens security by requiring additional verification factors.

Password Policies and Shadow File Management

Password policies in Linux enforce rules for password complexity, aging, reuse restrictions, and account lockout thresholds to enhance system security. These policies can be configured through files like /etc/login.defs and /etc/pam.d/common-password, as well as managed using utilities such as chage for password expiry.

Sensitive password information is securely stored in /etc/shadow, which is accessible only by privileged processes, ensuring that passwords are not exposed to regular users.

Example password aging configuration entry:

text
PASS_MAX_DAYS 90
PASS_MIN_DAYS 7
PASS_WARN_AGE 14

sudo Configuration and Auditing

sudo allows authorized users to execute commands with elevated privileges in a secure manner. Its configuration, managed via /etc/sudoers and edited safely with visudo, provides fine-grained control over which users or groups can run specific commands.

Monitoring and auditing sudo usage is critical for compliance and security, as it logs executed commands along with timestamps in the system log or journal for verification and review.


Example sudoers entry allowing user to run specific command without password:

text
username ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart httpd

PAM (Pluggable Authentication Modules) Fundamentals

Pluggable Authentication Modules (PAM) abstracts authentication mechanisms into modular components, enabling system administrators to implement flexible, layered authentication policies without modifying applications. Configuration files located in /etc/pam.d/ specify modules for authentication, account, session, and password management.


Common modules include

pam_unix.so for traditional password authentication,

pam_tally2.so or pam_faillock.so for brute-force protection, and

pam_google_authenticator.so for two-factor authentication.


PAM also allows chaining multiple steps, making it possible to integrate multi-factor or external authentication mechanisms seamlessly.

Multi-Factor Authentication (MFA) 

Multi-Factor Authentication (MFA) adds an extra layer of verification beyond traditional passwords, using methods such as one-time codes, hardware tokens, or biometric factors.

Common PAM-integrated MFA solutions include Google Authenticator and hardware-based devices like YubiKey. By requiring multiple forms of authentication, MFA significantly enhances security and reduces the risk associated with compromised passwords.