Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Perform Auditing in Linux Using Auditd

Auditing is a crucial aspect of system administration that helps in tracking activities on a system, ensuring compliance, and detecting unauthorized access. In the Linux environment, auditing can be effectively performed using the Audit daemon, commonly known as "auditd." This tool provides comprehensive logging of system events and user activities.

Examples:

  1. Installing Auditd:

    To start using auditd, you need to ensure it is installed on your Linux system. Most Linux distributions provide it in their default repositories.

    sudo apt-get update
    sudo apt-get install auditd audispd-plugins

    For Red Hat-based systems:

    sudo yum install audit
  2. Configuring Audit Rules:

    Audit rules define what activities should be logged. These rules can be set in the /etc/audit/audit.rules file. Below is an example of how to log all changes to the /etc/passwd file:

    -w /etc/passwd -p wa -k passwd_changes

    Here, -w specifies the file to watch, -p sets the permissions (write and attribute change), and -k is a key to identify the rule.

  3. Starting and Enabling Auditd:

    Once auditd is installed and configured, start the service and enable it to start on boot:

    sudo systemctl start auditd
    sudo systemctl enable auditd
  4. Viewing Audit Logs:

    Audit logs are stored in /var/log/audit/audit.log. You can use ausearch to query these logs. For example, to find all events related to the passwd_changes key:

    ausearch -k passwd_changes
  5. Generating Audit Reports:

    You can generate reports from audit logs using the aureport command. For example, to generate a summary report of all login events:

    aureport -l
  6. Advanced Audit Rules:

    To audit all commands executed by users, add the following rule:

    -a always,exit -F arch=b64 -S execve -k user_commands

    This rule logs every executed command (execve system call) for 64-bit architecture.

By following these examples, you can set up a robust auditing system on your Linux environment, enabling you to monitor and log various system activities effectively. This setup is crucial for maintaining security and ensuring compliance with organizational policies.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.