Admin

Artificial Intelligence

Linux Security Hardening: CIS Level 2 Compliance Checklist

Linux hardening checklist for CIS Benchmark Level 2 compliance. Secure your systems with actionable steps and achieve robust security.

By Sujay SinghPublished: July 13, 202616 min read15 views✓ Fact Checked
Linux Security Hardening: CIS Level 2 Compliance Checklist
Linux Security Hardening: CIS Level 2 Compliance Checklist

Overview: Hardening Linux for CIS Benchmark Level 2 Compliance in AI Infrastructure

In the rapidly evolving landscape of Artificial Intelligence, the underlying infrastructure's security is paramount. As AI models become more complex and handle increasingly sensitive data, the attack surface expands, making robust security measures indispensable. One of the most respected and comprehensive frameworks for securing IT systems is the Center for Internet Security (CIS) Benchmarks. These globally recognized configuration guidelines are developed through a consensus process by cybersecurity experts, providing a strong foundation for hardening various systems.

This article delves into achieving CIS Benchmark Level 2 compliance for Linux systems, a critical endeavor for any organization, especially those leveraging Linux as the backbone for their AI development, training, and deployment environments. While Level 1 provides a good starting point, addressing essential security recommendations without impeding business functionality, Level 2 is designed for environments requiring a higher degree of security. It delves deeper into reducing the attack surface, often requiring more extensive configuration changes that might impact application compatibility if not meticulously planned and tested. For AI infrastructure, where data integrity, model confidentiality, and uninterrupted operational security are non-negotiable, Level 2 compliance is not merely a recommendation but a strategic imperative.

Achieving Level 2 compliance involves a comprehensive overhaul of system configurations, spanning file system permissions, network settings, authentication policies, logging, and more. This detailed checklist will guide you through the practical steps, including real-world CLI commands and configuration examples, to fortify your Linux servers against prevalent threats, ensuring your AI workloads run on a truly secure foundation.

Prerequisites

Before embarking on the journey to CIS Benchmark Level 2 compliance, ensure you have the following in place:

  • Target Operating System: This guide primarily focuses on Red Hat Enterprise Linux (RHEL) 8/9 or CentOS Stream 8/9, as CIS benchmarks often provide specific guidance for these distributions. While many concepts apply broadly, command syntax and file paths may differ slightly for other distributions like Ubuntu.
  • Administrative Access: You must have root privileges or a user with sudo access configured to execute system-level commands.
  • Comprehensive Backup: Performing a full system backup or creating a snapshot (in virtualized or cloud environments) is absolutely critical. Many Level 2 recommendations involve significant system changes that, if misconfigured, could render your system unbootable or inaccessible.
  • Understanding of Linux Fundamentals: A solid grasp of Linux command-line operations, file system structure, and basic networking concepts is essential.
  • Network Connectivity: Ensure your system has internet connectivity to download necessary packages and updates.
  • CIS Benchmark Document: While this article provides a practical checklist, always refer to the official CIS Benchmark for RHEL 8 or 9 (or your specific OS version) for the most granular and up-to-date recommendations. This document is your ultimate source of truth for compliance auditing.
  • Testing Environment: Ideally, first implement these changes in a non-production or staging environment identical to your production setup to identify any potential application incompatibilities or operational issues.

Step-by-Step Implementation: Linux Hardening Checklist for CIS Benchmark Level 2

This section provides a detailed, step-by-step guide to implementing key CIS Benchmark Level 2 recommendations. Remember, the CIS Benchmark document is extensive, and this guide covers the most impactful and representative controls. Always refer to the official benchmark for a complete list.

1. Initial Setup and Package Management

1.1 Ensure all system packages are up to date

Keeping your system updated patches known vulnerabilities, which is a foundational security practice.


sudo dnf update -y
sudo dnf upgrade -y
sudo dnf autoremove -y

1.2 Remove unused packages and services

Minimize the attack surface by uninstalling software and disabling services that are not essential for your AI workloads.


# List installed packages (example for identifying candidates for removal)
sudo dnf list installed

# Example: Remove an unnecessary package (e.g., telnet-server)
sudo dnf remove telnet-server -y

# Disable and stop unnecessary services
sudo systemctl list-unit-files --type=service | grep enabled
sudo systemctl disable 
sudo systemctl stop 

2. File System Configuration and Permissions

2.1 Mount Options for Critical Partitions

Apply restrictive mount options to partitions like /tmp, /var/tmp, /dev/shm, and potentially user home directories to prevent execution of arbitrary code, device usage, or set-user-ID/set-group-ID bit usage.

Edit /etc/fstab to add nodev, noexec, and nosuid options. If these are separate partitions, ensure they are configured. If /tmp is a subdirectory of /, consider creating a dedicated partition or using tmpfs with these options.


# Example for /tmp (if it's a separate partition)
# UUID=xxxx-xxxx-xxxx-xxxx /tmp xfs defaults,nodev,nosuid,noexec 0 0

# Example for /dev/shm (using tmpfs)
# tmpfs /dev/shm tmpfs defaults,nodev,nosuid,noexec 0 0

# After modifying /etc/fstab, remount the partitions or reboot
sudo mount -o remount,nodev,nosuid,noexec /tmp
sudo mount -o remount,nodev,nosuid,noexec /dev/shm

2.2 Enable the Sticky Bit on World-Writable Directories

Ensure that only the owner of a file can delete or rename it in world-writable directories like /tmp.


sudo chmod +t /tmp
sudo chmod +t /var/tmp

2.3 Restrict Permissions on Sensitive Files

Ensure that critical system files containing user information and authentication details have appropriate restrictive permissions.


# /etc/passwd
sudo chown root:root /etc/passwd
sudo chmod 644 /etc/passwd

# /etc/shadow
sudo chown root:root /etc/shadow
sudo chmod 000 /etc/shadow

# /etc/gshadow
sudo chown root:root /etc/gshadow
sudo chmod 000 /etc/gshadow

# /etc/group
sudo chown root:root /etc/group
sudo chmod 644 /etc/group

# /etc/sudoers (and files in /etc/sudoers.d/)
sudo chown root:root /etc/sudoers
sudo chmod 440 /etc/sudoers
# For files in /etc/sudoers.d/
sudo find /etc/sudoers.d/ -type f -exec chown root:root {} \;
sudo find /etc/sudoers.d/ -type f -exec chmod 440 {} \;

3. Network Configuration

3.1 Disable Unused Network Protocols (e.g., IPv6 if not needed)

If your AI infrastructure does not require IPv6, disable it to reduce the attack surface.

Edit /etc/sysctl.d/99-sysctl.conf (or create a new file like /etc/sysctl.d/cis.conf):


net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Apply the changes:


sudo sysctl -p /etc/sysctl.d/cis.conf

3.2 Harden Network Kernel Parameters (sysctl)

Implement various kernel-level network hardening measures to protect against common network attacks.

Edit /etc/sysctl.d/cis.conf (or your preferred sysctl configuration file):


# Disable IP forwarding (if not a router)
net.ipv4.ip_forward = 0
net.ipv6.conf.all.forwarding = 0

# Disable source routing
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv6.conf.all.accept_source_route = 0
net.ipv6.conf.default.accept_source_route = 0

# Disable ICMP redirects
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0

# Enable ignore ICMP broadcast requests
net.ipv4.icmp_echo_ignore_broadcasts = 1

# Enable bad error message protection
net.ipv4.icmp_ignore_bogus_error_responses = 1

# Enable SYN flood protection
net.ipv4.tcp_syncookies = 1

# Log martian packets
net.ipv4.conf.all.log_martians = 1
net.ipv4.conf.default.log_martians = 1

# Disable IP Spoofing protection
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1

Apply the changes:


sudo sysctl -p /etc/sysctl.d/cis.conf

3.3 Configure Firewall (firewalld/iptables)

Implement a strict firewall policy, allowing only necessary inbound and outbound connections. For AI workloads, this might include SSH, specific API ports, and potentially internal network communication ports.


# Using firewalld (default on RHEL/CentOS)
# Ensure firewalld is running
sudo systemctl enable firewalld --now

# Set default zone to block or drop
sudo firewall-cmd --set-default-zone=drop

# Allow SSH (port 22, consider changing it)
sudo firewall-cmd --permanent --add-service=ssh
# If using a custom SSH port, e.g., 2222
# sudo firewall-cmd --permanent --remove-service=ssh
# sudo firewall-cmd --permanent --add-port=2222/tcp

# Allow HTTP/HTTPS if serving web applications or APIs
# sudo firewall-cmd --permanent --add-service=http
# sudo firewall-cmd --permanent --add-service=https

# Allow specific ports for AI services (e.g., Jupyter notebooks, custom APIs)
# sudo firewall-cmd --permanent --add-port=8888/tcp
# sudo firewall-cmd --permanent --add-port=5000/tcp

# Reload firewalld to apply changes
sudo firewall-cmd --reload

# Verify rules
sudo firewall-cmd --list-all

4. Authentication and Authorization

4.1 Implement Strong Password Policies

Enforce strong password complexity, length, and expiration using pam_pwquality and chage.

Edit /etc/security/pwquality.conf:


# Minimum password length (CIS recommends 14 for L2)
minlen = 14
# Require at least one uppercase, lowercase, digit, and special character
dcredit = -1
ucredit = -1
ocredit = -1
lcredit = -1
# Max consecutive identical characters
maxrepeat = 3
# Do not allow passwords to be dictionary words
dictcheck = 1
# Number of characters that must be different from the old password (CIS L2: 8)
difok = 8

Configure password aging in /etc/login.defs:


PASS_MAX_DAYS   90   # Maximum days a password may be used (CIS L2: 90)
PASS_MIN_DAYS   7    # Minimum days before password can be changed (CIS L2: 7)
PASS_WARN_AGE   14   # Days warning before password expiration (CIS L2: 14)

Apply these settings to existing users:


sudo chage --maxdays 90 --mindays 7 --warndays 14 

4.2 Configure Account Lockout

Prevent brute-force attacks by locking out accounts after several failed login attempts using pam_faillock.

Edit /etc/pam.d/system-auth and /etc/pam.d/password-auth. Add the following lines at the top of the auth section:


auth        required      pam_faillock.so preauth audit deny=5 unlock_time=900
auth        sufficient    pam_unix.so try_first_pass
auth        [default=die] pam_faillock.so authfail audit deny=5 unlock_time=900

And in the account section:


account     required      pam_faillock.so

This configuration locks an account for 15 minutes (900 seconds) after 5 failed attempts.

4.3 SSH Hardening

Secure SSH access, which is often the primary remote access vector for AI servers.

Edit /etc/ssh/sshd_config:

  • Disable Root Login:
  • PermitRootLogin no
  • Disable Password Authentication (use SSH keys):
  • PasswordAuthentication no
  • Disable Empty Passwords:
  • PermitEmptyPasswords no
  • Limit Users (optional but recommended):
  • AllowUsers  
  • Change Default SSH Port (optional but good for obscurity):
  • Port 2222
  • Disable X11 Forwarding (unless explicitly needed):
  • X11Forwarding no
  • Set ClientAliveInterval and ClientAliveCountMax:
  • ClientAliveInterval 300
    ClientAliveCountMax 0
  • Disable Host-based authentication:
  • HostbasedAuthentication no
  • Disable challenging for authentication if a user already has a valid key:
  • ChallengeResponseAuthentication no

After changes, restart the SSH service:


sudo systemctl restart sshd

5. Logging and Auditing

5.1 Configure Auditd

Ensure comprehensive auditing of system events, especially those related to security, using auditd. This is crucial for detecting and investigating breaches in AI environments.


# Ensure auditd is enabled and running
sudo systemctl enable auditd --now

# Add audit rules (example for critical file access, privilege escalation)
# Edit /etc/audit/rules.d/cis.rules or append to /etc/audit/audit.rules

# Monitor access to /etc/shadow
-w /etc/shadow -p wa -k audit_shadow_access

# Monitor access to /etc/passwd
-w /etc/passwd -p wa -k audit_passwd_access

# Monitor changes to system immutable files
-a always,exit -F arch=b64 -S chmod -S fchmod -S fchmodat -F a2=0x1000 -k perm_mod
-a always,exit -F arch=b32 -S chmod -S fchmod -S fchmodat -F a2=0x1000 -k perm_mod

# Monitor successful and unsuccessful attempts to use privileged commands
-a always,exit -F arch=b64 -S execve -F success=0 -k execve_fail
-a always,exit -F arch=b64 -S execve -F success=1 -k execve_success
-a always,exit -F arch=b32 -S execve -F success=0 -k execve_fail
-a always,exit -F arch=b32 -S execve -F success=1 -k execve_success

# Immutable audit configuration (to prevent tampering with audit logs)
-e 2

After adding rules, reload auditd:


sudo augenrules --load
# Or restart auditd
# sudo systemctl restart auditd

5.2 Configure Rsyslog

Ensure all system logs are properly configured, stored, and protected. Consider remote syslog for centralized logging.

Edit /etc/rsyslog.conf to ensure logging levels are appropriate and logs are stored securely.


# Ensure appropriate permissions on log files (CIS recommends 640 or tighter for sensitive logs)
# Example for /var/log/messages
sudo chmod 640 /var/log/messages
sudo chown root:adm /var/log/messages # Or root:syslog depending on distro

# Configure remote syslog (optional, but highly recommended for L2)
# Add these lines to /etc/rsyslog.conf to send logs to a remote server
# *.* @192.168.1.100:5140  # UDP
# *.* @@192.168.1.100:5140 # TCP (more reliable)

Restart rsyslog:


sudo systemctl restart rsyslog

6. System Access, Banners, and Software

6.1 Configure Warning Banners

Display appropriate legal warning banners for local and SSH logins.

Edit /etc/issue (for local logins) and /etc/issue.net (for SSH, if configured in sshd_config):


# Example content for /etc/issue and /etc/issue.net
-------------------------------------------------------------------------------
  Unauthorized access to this system is forbidden and will be prosecuted by law.
  By continuing to use this system you imply your acceptance of these terms.
-------------------------------------------------------------------------------

For SSH, ensure Banner /etc/issue.net is uncommented in /etc/ssh/sshd_config and restart sshd.

6.2 Disable Unnecessary Services

Review and disable any services not explicitly required for your AI applications or system operation. This includes services like FTP, telnet, NFS, CUPS, etc.


# List all enabled services
sudo systemctl list-unit-files --type=service | grep enabled

# Disable and stop an example service (e.g., nfs-server)
sudo systemctl disable nfs-server --now

6.3 Restrict Core Dump Usage

Prevent core dumps from containing sensitive information by restricting their creation.

Edit /etc/security/limits.conf:


* hard core 0

Also, ensure DefaultLimitCORE=0 is set in /etc/systemd/system.conf and /etc/systemd/user.conf.


# In /etc/systemd/system.conf and /etc/systemd/user.conf
DefaultLimitCORE=0

Reload systemd and reboot for full effect:


sudo systemctl daemon-reload
# sudo reboot

7. Boot Loader Configuration

7.1 Set GRUB Password

Protect the GRUB boot loader with a password to prevent unauthorized modification of boot parameters or entering single-user mode.


# Generate a GRUB password hash
sudo grub2-mkpasswd-pbkdf2
# You will be prompted to enter and confirm a password.
# It will output a hash like:
# grub.pbkdf2.sha512.10000.A7B8C9D0E1F2...

# Edit /etc/grub.d/40_custom (or /etc/grub.d/00_header for a more direct approach)
# Add the following lines, replacing the hash with your generated one:
# set superusers=""
# password_pbkdf2  

# Update GRUB configuration
sudo grub2-mkconfig -o /boot/grub2/grub.cfg

7.2 Restrict Single-User Mode

Require authentication to enter single-user mode or maintenance mode.

Edit /usr/lib/systemd/system/rescue.service and /usr/lib/systemd/system/emergency.service. Ensure the ExecStart line uses sulogin:


# In rescue.service and emergency.service
ExecStart=-/usr/sbin/sulogin

Reload systemd daemon:


sudo systemctl daemon-reload

Security Considerations

Implementing CIS Level 2 hardening is a significant undertaking with several critical considerations:

  • Application Compatibility: The most common challenge is that strict Level 2 controls (e.g., noexec on /tmp, restrictive permissions, disabled services) can break existing applications or services that rely on less secure configurations. Thorough testing in a staging environment is non-negotiable before deploying to production, especially for complex AI frameworks and custom applications.
  • Performance Overhead: While generally minimal for most controls, extensive auditing with auditd, kernel parameter changes, and certain encryption measures can introduce a slight performance overhead. This needs to be evaluated against the performance requirements of your AI workloads.
  • Operational Complexity: A hardened system is inherently more complex to manage and troubleshoot. Access restrictions, mandatory authentication for single-user mode, and detailed logging require trained personnel and well-documented procedures.
  • False Sense of Security: Compliance with CIS Benchmarks provides a strong security baseline, but it is not a silver bullet. It must be part of a broader security strategy that includes threat modeling, continuous monitoring, vulnerability management, and incident response.
  • Maintenance Burden: Hardening is not a one-time event. New vulnerabilities emerge, and system configurations can drift. Regular re-auditing and maintenance are essential to sustain compliance and security posture.

Best Practices

  • Automate Everything: Manually applying these changes across multiple servers is error-prone and unsustainable. Leverage configuration management tools like Ansible, Puppet, Chef, or SaltStack. These tools allow you to define your desired state, track changes, and ensure consistency across your fleet.
  • "In the realm of AI, where scalability and rapid deployment are key, automation isn't just a convenience – it's a security imperative. Hardening a single server manually is tedious; hardening a thousand is impossible without robust automation." - Sujay Singh

  • Baseline and Drift Detection: Establish a golden image or a configuration baseline for your hardened systems. Implement tools and processes to regularly check for configuration drift from this baseline.
  • Regular Audits and Scans: Utilize CIS-CAT Pro Assessor or other compliance scanning tools to regularly audit your systems against the benchmark. Combine this with vulnerability scanning (e.g., Nessus, OpenVAS) and penetration testing.
  • Principle of Least Privilege: Continuously review user accounts, service accounts, and their permissions. Grant only the minimum necessary privileges required for operations.
  • Comprehensive Patch Management: Beyond initial updates, establish a consistent and timely patch management strategy for the OS, libraries, and all installed software.
  • Intrusion Detection/Prevention Systems (IDS/IPS): Complement host-level hardening with network-based IDS/IPS to detect and prevent malicious traffic patterns.
  • Centralized Logging and SIEM: Forward all system and application logs to a centralized Security Information and Event Management (SIEM) system. This enables correlation of events, real-time alerting, and long-term forensic analysis.
  • Incident Response Plan: Develop and regularly test an incident response plan. Know what to do when a security incident occurs, even on a hardened system.
  • Documentation: Meticulously document all configuration changes, exceptions, and the rationale behind them. This is invaluable for troubleshooting, compliance audits, and onboarding new team members.
  • Regular Training: Ensure that all personnel managing the AI infrastructure are trained on security best practices and the specific hardening measures implemented.

FAQ

Q1: What is the fundamental difference between CIS Level 1 and Level 2 Benchmarks?

CIS Level 1 Benchmarks provide a solid foundation of security without impeding business functionality. They focus on essential security controls that are relatively easy to implement and have minimal impact on system usability or performance. Level 2 Benchmarks, on the other hand, are designed for environments requiring a higher degree of security. They implement more stringent controls, often reducing the attack surface significantly, but may require more extensive configuration changes and potentially impact application compatibility or system performance. Level 2 is typically recommended for systems handling sensitive data, critical infrastructure, or those subject to strict regulatory compliance (e.g., HIPAA, PCI DSS).

Q2: Will applying CIS Level 2 hardening automatically break my existing AI applications?

Not automatically, but it is a significant risk that must be thoroughly managed. CIS Level 2 involves very restrictive configurations, such as disabling unnecessary services, applying noexec mounts to temporary directories, and tightening file permissions. Many AI applications, especially those developed in-house or using older frameworks, might assume a more permissive environment. For example, some applications might try to execute scripts from /tmp or require specific network ports to be open that a Level 2 firewall policy would block. Therefore, rigorous testing in a non-production environment that mirrors your production setup is crucial to identify and mitigate any compatibility issues before deployment.

Q3: Can I automate the process of checking for CIS Level 2 compliance and applying fixes?

Absolutely, and it's highly recommended. Manual compliance checks and remediation are time-consuming and prone to human error, especially for Level 2's extensive requirements. Tools like CIS-CAT Pro Assessor can automate the auditing process, generating detailed reports on compliance status. For automated remediation, configuration management tools such as Ansible, Puppet, Chef, or SaltStack are ideal. You can define playbooks, manifests, or recipes that enforce the desired CIS Level 2 configurations across your Linux fleet, ensuring consistency and reducing the operational burden. This automation also facilitates continuous compliance by allowing regular re-application of the baseline configurations.

Conclusion

Securing the

📧

Enjoyed this article?

Get articles like this delivered to your inbox daily. Join 10,000+ tech professionals.

Written By

Sujay Singh

Technology Expert / Cloud Architect at Virtual Venture covering AI, cloud computing, cybersecurity, and emerging tech trends.

Sources & References

• Official company announcements and press releases

• Industry reports from Gartner, IDC, and Statista

• Peer-reviewed research and technical documentation

• On-record statements from industry experts

Last verified: July 13, 2026

Fact-checked by TechNews Venture editorial team

Leave a Comment

Comments are moderated and will appear after review.