This Ansible playbook is designed to harden the operating system to meet security compliance requirements for CISCAT scans. The playbook includes various roles and tasks to configure system settings, install necessary packages, and enforce security policies.
- Installs and initializes AIDE (Advanced Intrusion Detection Environment).
- Creates and enables systemd services and timers for AIDE.
- Ensures cryptographic mechanisms are used to protect the integrity of audit tools.
- Sets ownership and permissions for cron-related directories and files.
- Ensures crontab is restricted to authorized users.
- Configures system-wide cryptographic policies to disable SHA1, CBC mode ciphers for SSH, and weak MAC algorithms.
- Prevent loading and blacklist the
cramfs
module. - Prevent loading and blacklist the
jffs2
module. - Prevent loading and blacklist the
usb-storage
module. - Unload these modules from the running kernel.
- Ensure journald is configured to compress large log files.
- Ensure journald is configured to write logfiles to persistent disk
- Ensures kernel sysctl settings (
randomize_va_space
andyama.ptrace_scope
) are persisted and applied.
- Configures and enforces various network-related sysctl settings.
- Stops and removes
rpcbind
package.
- Sets password lockout policies.
- Ensures password quality requirements are enforced.
- Sets password history requirements.
- Configures UMASK settings to be more restrictive.
- Ensures default user shell timeout is configured.
- Configures sysctl settings for kernel parameters.
- Configures default file permissions for rsyslog and ensures the service is restarted.
- Set ownership and permissions for SSH configuration files.
- Ensure sshd settings are configured.
- Ensures sudo commands use a pseudo-terminal (pty).
- Ensures sudo log file exists and is properly configured.
- Ensure /tmp is a separate partition.
-
Create an inventory file: Create a file named
inventory.ini
and list your target machines:[all] server1(host-name) ansible_host=10.49.41.111
-
Run the playbook:
ansible-playbook -i inventory.ini os_hardening.yaml