CompTIA Linux+ (XK0-005) Domain 2: Security

Domain Overview

This domain ensures Linux system confidentiality, integrity, and availability. Topics include file permissions, PAM, firewall setup, SELinux/AppArmor, SSH hardening, and log auditing.

1. User, Group, and File Security

Linux systems rely heavily on user and group management for securing access to resources:

Authentication and PAM

Pluggable Authentication Modules (PAM) provide a flexible and modular framework for managing authentication on Linux systems. PAM allows administrators to define how users are authenticated, authorized, and managed during login and other system activities.

Key Features of PAM:

Common PAM Modules:

Configuring PAM:

PAM configurations are stored in the /etc/pam.d/ directory, with each file corresponding to a specific service (e.g., sshd, login, sudo). Each configuration file contains a stack of rules, where each rule specifies a module and its behavior.

Example: Enforcing Password Complexity

To enforce password complexity using pam_pwquality.so, edit the /etc/pam.d/common-password file and add the following line:

      password requisite pam_pwquality.so retry=3 minlen=12 dcredit=-1 ucredit=-1 ocredit=-1 lcredit=-1
        

This configuration enforces the following rules:

Example: Locking Accounts After Failed Logins

To lock user accounts after three failed login attempts using pam_faillock.so, edit the /etc/pam.d/common-auth file and add the following lines:

      auth required pam_faillock.so preauth silent deny=3 unlock_time=600
      auth [default=die] pam_faillock.so authfail deny=3 unlock_time=600
      account required pam_faillock.so
        

This configuration does the following:

Best Practices for PAM Configuration:

Additional Resources:

3. Firewalls & SELinux

Securing Linux systems requires a combination of network-level protection and system-level access controls. Host-based firewalls like UFW and Firewalld provide network traffic filtering, while SELinux and AppArmor enforce Mandatory Access Control (MAC) policies to restrict system access.

Host-Based Firewalls

Firewalls are essential for controlling inbound and outbound network traffic. They allow administrators to define rules that permit or deny traffic based on IP addresses, ports, and protocols.

1. UFW (Uncomplicated Firewall)

UFW is a user-friendly firewall management tool for Debian-based systems. It simplifies the process of configuring iptables rules.

2. Firewalld

Firewalld is a dynamic firewall management tool for Red Hat-based systems. It supports zones, which allow different rules for different network interfaces.

Mandatory Access Control (MAC)

MAC systems like SELinux and AppArmor enforce strict access controls by confining processes and users to only the resources explicitly allowed by security policies.

1. SELinux (Security-Enhanced Linux)

SELinux is a powerful MAC system that enforces security policies at the kernel level. It is commonly used in Red Hat-based distributions.

2. AppArmor

AppArmor is an alternative to SELinux that uses profiles to restrict the capabilities of individual applications. It is commonly used in Ubuntu-based systems.

Best Practices for Firewalls & MAC Systems

Additional Resources

4. System Security Features

Hardening Linux systems is essential to reduce attack surfaces and protect against unauthorized access. This involves implementing advanced security mechanisms such as SELinux, AppArmor, and file integrity monitoring tools.

Key System Security Features:

Best Practices for System Security:

Additional Resources:

5. Log Management and Auditing

Effective log management and auditing are critical for detecting suspicious activities, ensuring compliance with security policies, and maintaining system integrity. Linux provides robust tools and mechanisms for monitoring, analyzing, and auditing system logs.

Key Log Files to Monitor:

Using auditd for Advanced Auditing:

The auditd (Audit Daemon) service is a powerful tool for tracking system events and monitoring access to critical files. It is commonly used to meet compliance requirements and detect unauthorized activities.

Using journalctl for Log Analysis:

The journalctl command is used to query and view logs managed by systemd. It provides powerful filtering options for analyzing logs.

Best Practices for Log Management:

Additional Resources:

6. Important Commands Summary

Mastering these commands is essential for efficiently managing Linux security settings:

Conclusion

Linux security is a multi-layered discipline involving access control, authentication management, network protection, system hardening, and auditing. Mastery of these concepts prepares you for real-world Linux administration and is critical for passing the CompTIA Linux+ XK0-005 exam.

Continue expanding your Linux knowledge: Explore Domain 3: Scripting and Automation next!