CIS Amazon Linux 2 Benchmark

Secure configuration guidelines for Amazon Linux 2 on AWS EC2 instances

v2.0.0 September 2025

Overview

▶

This CIS Benchmark provides prescriptive guidance for establishing a secure configuration posture for Amazon Linux 2 running on AWS EC2. Recommendations cover filesystem configuration, package management, services, network parameters, iptables, auditing, SSH/PAM hardening, and system maintenance.

~200Recommendations
6Sections
2Profile Levels
SectionAreaFocus
1Initial SetupFilesystems, packages, updates
2ServicesDaemons, clients
3Networksysctl, iptables
4Loggingauditd, rsyslog
5AccessSSH, PAM, passwords
6MaintenanceFile permissions, accounts

Profile Definitions

▶
ProfileDescriptionIntended Use
L1Level 1 — StandardEssential security for all Amazon Linux 2 deployments; minimal performance impact.
L2Level 2 — HardenedAdvanced hardening for PCI-DSS, HIPAA, or high-security environments.

1 — Initial Setup

▶

1.1 Filesystem Configuration

▶
1.1.1 Ensure /tmp Is a Separate Partition (Automated)
L1 Auto
Description

This recommendation verifies that /tmp Is a Separate Partition on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
findmnt --kernel /tmp
systemctl is-enabled tmp.mount
Remediation
systemctl unmask tmp.mount
systemctl enable --now tmp.mount

# Or add to /etc/fstab:
# tmpfs /tmp tmpfs defaults,rw,nosuid,nodev,noexec 0 0
1.1.2 Ensure nodev Option Is Set on /tmp (Automated)
L1 Auto
Description

This recommendation verifies that nodev Option Is Set on /tmp on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
findmnt --kernel /tmp | grep nodev
Remediation
# Add nodev to /tmp mount options in /etc/fstab
mount -o remount /tmp
1.1.3 Ensure nosuid Option Is Set on /tmp (Automated)
L1 Auto
Description

This recommendation verifies that nosuid Option Is Set on /tmp on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
findmnt --kernel /tmp | grep nosuid
Remediation
# Add nosuid to /tmp mount options in /etc/fstab
mount -o remount /tmp
1.1.4 Ensure noexec Option Is Set on /tmp (Automated)
L1 Auto
Description

This recommendation verifies that noexec Option Is Set on /tmp on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
findmnt --kernel /tmp | grep noexec
Remediation
# Add noexec to /tmp mount options in /etc/fstab
mount -o remount /tmp
1.1.5 Ensure /var Is a Separate Partition (Automated)
L2 Auto
Description

This recommendation verifies that /var Is a Separate Partition on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
findmnt --kernel /var
# Verify /var is a separate partition
Remediation
# Partition /var at install time. For existing systems:
lvcreate -L 10G -n var_lv amz_vg
mkfs.xfs /dev/amz_vg/var_lv
# Update /etc/fstab
1.1.6 Ensure /home Is a Separate Partition (Automated)
L2 Auto
Description

This recommendation verifies that /home Is a Separate Partition on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
findmnt --kernel /home
# Verify /home is a separate partition
findmnt --kernel /home | grep nodev
Remediation
# Partition /home at install time
# Add nodev to mount options in /etc/fstab:
# /dev/amz_vg/home_lv /home xfs defaults,nodev 0 0

1.2 Updates & Repositories

▶
1.2.1 Ensure GPG Check Is Enabled for All Repos (Automated)
L1 Auto
Description

This recommendation verifies that GPG Check Is Enabled for All Repos on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
grep -r 'gpgcheck' /etc/yum.repos.d/
yum repolist
# Verify gpgcheck=1 for all repos
Remediation
sed -i 's/^gpgcheck=0/gpgcheck=1/' /etc/yum.repos.d/*.repo

# Also ensure in /etc/yum.conf:
sed -i 's/^gpgcheck=0/gpgcheck=1/' /etc/yum.conf
1.2.2 Ensure Security Updates Are Applied (Automated)
L1 Auto
Description

This recommendation verifies that Security Updates Are Applied on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
yum check-update --security 2>/dev/null
# Review pending security updates
Remediation
yum update -y --security
# Or full update:
yum update -y
1.2.3 Ensure Automatic Updates Are Configured (Automated)
L1 Auto
Description

This recommendation verifies that Automatic Updates Are Configured on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
systemctl is-enabled yum-cron
grep 'apply_updates' /etc/yum/yum-cron.conf
Remediation
yum install -y yum-cron
sed -i 's/^apply_updates.*/apply_updates = yes/' /etc/yum/yum-cron.conf
systemctl enable --now yum-cron

2 — Services

▶

2.1 Unnecessary Services

▶
2.1.1 Ensure Avahi Server Is Disabled (Automated)
L1 Auto
Description

This recommendation verifies that Avahi Server Is Disabled on the Amazon Linux 2 Linux operating system. Disabling or removing unnecessary components reduces the attack surface and limits potential vectors for exploitation.

Rationale

Running unnecessary components on the Amazon Linux 2 Linux operating system increases the attack surface and the risk of exploitation. Disabling or removing them follows the principle of least functionality and reduces exposure to known vulnerabilities.

Audit
systemctl is-active avahi-daemon
systemctl is-enabled avahi-daemon
Remediation
systemctl stop avahi-daemon
systemctl disable avahi-daemon
yum remove -y avahi
2.1.2 Ensure CUPS Is Disabled (Automated)
L1 Auto
Description

This recommendation verifies that CUPS Is Disabled on the Amazon Linux 2 Linux operating system. Disabling or removing unnecessary components reduces the attack surface and limits potential vectors for exploitation.

Rationale

Running unnecessary components on the Amazon Linux 2 Linux operating system increases the attack surface and the risk of exploitation. Disabling or removing them follows the principle of least functionality and reduces exposure to known vulnerabilities.

Audit
systemctl is-active cups
systemctl is-enabled cups
Remediation
systemctl stop cups
systemctl disable cups
yum remove -y cups
2.1.3 Ensure NFS Is Disabled Unless Required (Automated)
L1 Auto
Description

This recommendation verifies that NFS Is Disabled Unless Required on the Amazon Linux 2 Linux operating system. Disabling or removing unnecessary components reduces the attack surface and limits potential vectors for exploitation.

Rationale

Running unnecessary components on the Amazon Linux 2 Linux operating system increases the attack surface and the risk of exploitation. Disabling or removing them follows the principle of least functionality and reduces exposure to known vulnerabilities.

Audit
systemctl is-active nfs-server
systemctl is-enabled nfs-server
rpm -q nfs-utils
Remediation
systemctl stop nfs-server
systemctl disable nfs-server
systemctl mask nfs-server
2.1.4 Ensure rpcbind Is Disabled Unless Required (Automated)
L1 Auto
Description

This recommendation verifies that rpcbind Is Disabled Unless Required on the Amazon Linux 2 Linux operating system. Disabling or removing unnecessary components reduces the attack surface and limits potential vectors for exploitation.

Rationale

Running unnecessary components on the Amazon Linux 2 Linux operating system increases the attack surface and the risk of exploitation. Disabling or removing them follows the principle of least functionality and reduces exposure to known vulnerabilities.

Audit
systemctl is-active rpcbind
systemctl is-enabled rpcbind
rpm -q rpcbind
Remediation
systemctl stop rpcbind
systemctl disable rpcbind
systemctl mask rpcbind
2.1.5 Ensure SNMP Server Is Disabled (Automated)
L1 Auto
Description

This recommendation verifies that SNMP Server Is Disabled on the Amazon Linux 2 Linux operating system. Disabling or removing unnecessary components reduces the attack surface and limits potential vectors for exploitation.

Rationale

Running unnecessary components on the Amazon Linux 2 Linux operating system increases the attack surface and the risk of exploitation. Disabling or removing them follows the principle of least functionality and reduces exposure to known vulnerabilities.

Audit
systemctl is-active snmpd
systemctl is-enabled snmpd
Remediation
systemctl stop snmpd
systemctl disable snmpd
yum remove -y net-snmp

2.2 Service Clients

▶
2.2.1 Ensure telnet Client Is Not Installed (Automated)
L1 Auto
Description

This recommendation verifies that telnet Client Is Not Installed on the Amazon Linux 2 Linux operating system. Disabling or removing unnecessary components reduces the attack surface and limits potential vectors for exploitation.

Rationale

Running unnecessary components on the Amazon Linux 2 Linux operating system increases the attack surface and the risk of exploitation. Disabling or removing them follows the principle of least functionality and reduces exposure to known vulnerabilities.

Audit
rpm -q telnet
# Should return: package telnet is not installed
Remediation
yum remove -y telnet
2.2.2 Ensure rsh Client Is Not Installed (Automated)
L1 Auto
Description

This recommendation verifies that rsh Client Is Not Installed on the Amazon Linux 2 Linux operating system. Disabling or removing unnecessary components reduces the attack surface and limits potential vectors for exploitation.

Rationale

Running unnecessary components on the Amazon Linux 2 Linux operating system increases the attack surface and the risk of exploitation. Disabling or removing them follows the principle of least functionality and reduces exposure to known vulnerabilities.

Audit
rpm -q rsh
# Should return: package rsh is not installed
Remediation
yum remove -y rsh
2.2.3 Ensure NIS Client Is Not Installed (Automated)
L1 Auto
Description

This recommendation verifies that NIS Client Is Not Installed on the Amazon Linux 2 Linux operating system. Disabling or removing unnecessary components reduces the attack surface and limits potential vectors for exploitation.

Rationale

Running unnecessary components on the Amazon Linux 2 Linux operating system increases the attack surface and the risk of exploitation. Disabling or removing them follows the principle of least functionality and reduces exposure to known vulnerabilities.

Audit
rpm -q ypbind
# Should return: package ypbind is not installed
Remediation
yum remove -y ypbind

3 — Network Configuration

▶

3.1 Network Parameters

▶
3.1.1 Ensure IP Forwarding Is Disabled (Automated)
L1 Auto
Description

This recommendation verifies that IP Forwarding Is Disabled on the Amazon Linux 2 Linux operating system. Disabling or removing unnecessary components reduces the attack surface and limits potential vectors for exploitation.

Rationale

Running unnecessary components on the Amazon Linux 2 Linux operating system increases the attack surface and the risk of exploitation. Disabling or removing them follows the principle of least functionality and reduces exposure to known vulnerabilities.

Audit
sysctl net.ipv4.ip_forward
# Should return 0
sysctl net.ipv6.conf.all.forwarding
# Should return 0
Remediation
echo 'net.ipv4.ip_forward = 0' > /etc/sysctl.d/60-disable-forward.conf
echo 'net.ipv6.conf.all.forwarding = 0' >> /etc/sysctl.d/60-disable-forward.conf
sysctl --system
3.1.2 Ensure Packet Redirect Sending Is Disabled (Automated)
L1 Auto
Description

This recommendation verifies that Packet Redirect Sending Is Disabled on the Amazon Linux 2 Linux operating system. Disabling or removing unnecessary components reduces the attack surface and limits potential vectors for exploitation.

Rationale

Running unnecessary components on the Amazon Linux 2 Linux operating system increases the attack surface and the risk of exploitation. Disabling or removing them follows the principle of least functionality and reduces exposure to known vulnerabilities.

Audit
sysctl net.ipv4.conf.all.send_redirects
sysctl net.ipv4.conf.default.send_redirects
# Both should return 0
Remediation
echo 'net.ipv4.conf.all.send_redirects = 0' >> /etc/sysctl.d/60-disable-forward.conf
echo 'net.ipv4.conf.default.send_redirects = 0' >> /etc/sysctl.d/60-disable-forward.conf
sysctl --system
3.1.3 Ensure ICMP Redirects Are Not Accepted (Automated)
L1 Auto
Description

This recommendation verifies that ICMP Redirects Are Not Accepted on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
sysctl net.ipv4.conf.all.accept_redirects
sysctl net.ipv4.conf.default.accept_redirects
Remediation
echo 'net.ipv4.conf.all.accept_redirects = 0' >> /etc/sysctl.d/60-netipv4.conf
echo 'net.ipv4.conf.default.accept_redirects = 0' >> /etc/sysctl.d/60-netipv4.conf
sysctl --system
3.1.4 Ensure Suspicious Packets Are Logged (Automated)
L1 Auto
Description

This recommendation verifies that Suspicious Packets Are Logged on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
sysctl net.ipv4.conf.all.log_martians
sysctl net.ipv4.conf.default.log_martians
# Both should return 1
Remediation
echo 'net.ipv4.conf.all.log_martians = 1' >> /etc/sysctl.d/60-netipv4.conf
echo 'net.ipv4.conf.default.log_martians = 1' >> /etc/sysctl.d/60-netipv4.conf
sysctl --system

3.2 Firewall (iptables)

▶
3.2.1 Ensure iptables Is Installed and Running (Automated)
L1 Auto
Description

This recommendation verifies that iptables Is Installed and Running on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
rpm -q iptables
iptables -L -n --line-numbers
ip6tables -L -n --line-numbers
Remediation
yum install -y iptables-services
systemctl enable --now iptables
systemctl enable --now ip6tables
3.2.2 Ensure Default Deny Policy Is Set (Automated)
L1 Auto
Description

This recommendation verifies that Default Deny Policy Is Set on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
iptables -L INPUT -n | head -3
# Verify default INPUT policy is DROP or REJECT
iptables -L FORWARD -n | head -3
# Verify FORWARD is DROP
Remediation
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
service iptables save
3.2.3 Ensure Loopback and Established Connections Are Allowed (Automated)
L1 Auto
Description

This recommendation verifies that Loopback and Established Connections Are Allowed on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
iptables -L INPUT -n | grep 'state ESTABLISHED'
# Verify established connections are allowed
Remediation
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
service iptables save
3.2.4 Ensure Unnecessary Rules Are Removed (Manual)
L1 Manual
Description

This recommendation verifies that Unnecessary Rules Are Removed on the Amazon Linux 2 Linux operating system. Disabling or removing unnecessary components reduces the attack surface and limits potential vectors for exploitation.

Rationale

Running unnecessary components on the Amazon Linux 2 Linux operating system increases the attack surface and the risk of exploitation. Disabling or removing them follows the principle of least functionality and reduces exposure to known vulnerabilities.

Audit
iptables -L INPUT -n | grep -v 'DROP\|ACCEPT\|REJECT\|Chain\|target'
# Review any unexpected rules
Remediation
# Remove unnecessary rules:
iptables -D INPUT <rule_number>
service iptables save

4 — Logging & Auditing

▶

4.1 Configure Auditing

▶
4.1.1 Ensure auditd Is Installed and Enabled (Automated)
L1 Auto
Description

This recommendation verifies that auditd Is Installed and Enabled on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
rpm -q audit
systemctl is-enabled auditd
systemctl is-active auditd
Remediation
yum install -y audit
systemctl enable --now auditd
4.1.2 Ensure Audit Log Size Is Configured (Automated)
L1 Auto
Description

This recommendation verifies that Audit Log Size Is Configured on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
grep -E '^max_log_file\b' /etc/audit/auditd.conf
grep 'max_log_file_action' /etc/audit/auditd.conf
Remediation
sed -i 's/^max_log_file\b.*/max_log_file = 8/' /etc/audit/auditd.conf
sed -i 's/^max_log_file_action.*/max_log_file_action = keep_logs/' /etc/audit/auditd.conf
service auditd restart
4.1.3 Ensure Identity Changes Are Audited (Automated)
L1 Auto
Description

This recommendation verifies that Identity Changes Are Audited on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
auditctl -l | grep -E 'passwd|shadow|group|gshadow|opasswd'
grep identity /etc/audit/rules.d/*.rules
Remediation
cat >> /etc/audit/rules.d/50-identity.rules << 'EOF'
-w /etc/group -p wa -k identity
-w /etc/passwd -p wa -k identity
-w /etc/gshadow -p wa -k identity
-w /etc/shadow -p wa -k identity
-w /etc/security/opasswd -p wa -k identity
EOF
augenrules --load
4.1.4 Ensure Sudoers Changes Are Audited (Automated)
L1 Auto
Description

This recommendation verifies that Sudoers Changes Are Audited on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
auditctl -l | grep scope
grep scope /etc/audit/rules.d/*.rules
Remediation
cat >> /etc/audit/rules.d/50-scope.rules << 'EOF'
-w /etc/sudoers -p wa -k scope
-w /etc/sudoers.d/ -p wa -k scope
EOF
augenrules --load

4.2 Configure Logging

▶
4.2.1 Ensure rsyslog Is Installed (Automated)
L1 Auto
Description

This recommendation verifies that rsyslog Is Installed on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
rpm -q rsyslog
systemctl is-enabled rsyslog
Remediation
yum install -y rsyslog
systemctl enable --now rsyslog
4.2.2 Ensure Remote Logging Is Configured (Automated)
L1 Auto
Description

This recommendation verifies that Remote Logging Is Configured on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
grep -E '^\*\.\*\s+@@' /etc/rsyslog.conf /etc/rsyslog.d/*.conf 2>/dev/null
Remediation
echo '*.* @@loghost.example.com:514' > /etc/rsyslog.d/50-remote.conf
systemctl restart rsyslog
4.2.3 Ensure Log File Permissions Are Configured (Automated)
L1 Auto
Description

This recommendation verifies that Log File Permissions Are Configured on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
find /var/log -type f -perm /037 -ls
stat -c '%a %U %G' /var/log/messages /var/log/secure
Remediation
chmod 640 /var/log/messages
chmod 640 /var/log/secure
find /var/log -type f -perm /037 -exec chmod 640 {} \;

5 — Access & Authentication

▶

5.1 SSH Server Configuration

▶
5.1.1 Ensure SSH Root Login Is Disabled (Automated)
L1 Auto
Description

This recommendation verifies that SSH Root Login Is Disabled on the Amazon Linux 2 Linux operating system. Disabling or removing unnecessary components reduces the attack surface and limits potential vectors for exploitation.

Rationale

Running unnecessary components on the Amazon Linux 2 Linux operating system increases the attack surface and the risk of exploitation. Disabling or removing them follows the principle of least functionality and reduces exposure to known vulnerabilities.

Audit
sshd -T | grep permitrootlogin
# Should return: permitrootlogin no
Remediation
sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config
systemctl reload sshd
5.1.2 Ensure SSH PermitEmptyPasswords Is Disabled (Automated)
L1 Auto
Description

This recommendation verifies that SSH PermitEmptyPasswords Is Disabled on the Amazon Linux 2 Linux operating system. Disabling or removing unnecessary components reduces the attack surface and limits potential vectors for exploitation.

Rationale

Running unnecessary components on the Amazon Linux 2 Linux operating system increases the attack surface and the risk of exploitation. Disabling or removing them follows the principle of least functionality and reduces exposure to known vulnerabilities.

Audit
sshd -T | grep permitemptypasswords
# Should return: permitemptypasswords no
Remediation
sed -i 's/^#\?PermitEmptyPasswords.*/PermitEmptyPasswords no/' /etc/ssh/sshd_config
systemctl reload sshd
5.1.3 Ensure SSH MaxAuthTries Is 4 or Less (Automated)
L1 Auto
Description

This recommendation verifies that SSH MaxAuthTries Is 4 or Less on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
sshd -T | grep maxauthtries
# Should return: maxauthtries 4 or less
Remediation
sed -i 's/^#\?MaxAuthTries.*/MaxAuthTries 4/' /etc/ssh/sshd_config
systemctl reload sshd
5.1.4 Ensure SSH Idle Timeout Is Configured (Automated)
L1 Auto
Description

This recommendation verifies that SSH Idle Timeout Is Configured on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
sshd -T | grep -E 'clientaliveinterval|clientalivecountmax'
Remediation
sed -i 's/^#\?ClientAliveInterval.*/ClientAliveInterval 300/' /etc/ssh/sshd_config
sed -i 's/^#\?ClientAliveCountMax.*/ClientAliveCountMax 3/' /etc/ssh/sshd_config
systemctl reload sshd
5.1.5 Ensure SSH Banner Is Configured (Automated)
L1 Auto
Description

This recommendation verifies that SSH Banner Is Configured on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
sshd -T | grep banner
# Should return: banner /etc/issue.net
Remediation
sed -i 's/^#\?Banner.*/Banner \/etc\/issue.net/' /etc/ssh/sshd_config
systemctl reload sshd

5.2 PAM & Password Settings

▶
5.2.1 Ensure Password Creation Requirements Are Configured (Automated)
L1 Auto
Description

This recommendation ensures that Password Creation Requirements Are Configured on the Amazon Linux 2 Linux operating system. Enforcing this requirement establishes a minimum security standard and prevents insecure configurations.

Rationale

Without this enforcement, the Amazon Linux 2 Linux operating system may accept insecure configurations that weaken overall security posture. Mandating this control ensures consistent protection against common attack vectors.

Audit
grep -E '^\s*minlen|dcredit|ucredit|ocredit|lcredit' /etc/security/pwquality.conf
Remediation
sed -i 's/^#\? *minlen.*/minlen = 14/' /etc/security/pwquality.conf
sed -i 's/^#\? *dcredit.*/dcredit = -1/' /etc/security/pwquality.conf
sed -i 's/^#\? *ucredit.*/ucredit = -1/' /etc/security/pwquality.conf
sed -i 's/^#\? *ocredit.*/ocredit = -1/' /etc/security/pwquality.conf
sed -i 's/^#\? *lcredit.*/lcredit = -1/' /etc/security/pwquality.conf
5.2.2 Ensure Password Reuse Is Limited (Automated)
L1 Auto
Description

This setting ensures that Password Reuse Is Limited on the Amazon Linux 2 Linux operating system. Restricting this capability limits potential abuse and enforces the principle of least privilege across the environment.

Rationale

Unrestricted access to this capability could allow unauthorized users or processes to perform actions beyond their intended scope. Applying least-privilege principles to the Amazon Linux 2 Linux operating system is essential for defense in depth.

Audit
grep -E 'pam_pwhistory|remember' /etc/pam.d/system-auth
Remediation
# In /etc/pam.d/system-auth, add or update:
# password requisite pam_pwhistory.so use_authtok remember=5 retry=3
sed -i '/pam_unix.so/i password    requisite     pam_pwhistory.so use_authtok remember=5 retry=3' /etc/pam.d/system-auth
5.2.3 Ensure Account Lockout Is Configured (Automated)
L1 Auto
Description

This recommendation verifies that Account Lockout Is Configured on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
grep pam_faillock /etc/pam.d/system-auth /etc/pam.d/password-auth
grep -E '^deny|^unlock_time' /etc/security/faillock.conf 2>/dev/null
Remediation
# Configure /etc/security/faillock.conf:
echo 'deny = 5' >> /etc/security/faillock.conf
echo 'unlock_time = 900' >> /etc/security/faillock.conf
echo 'fail_interval = 900' >> /etc/security/faillock.conf

# Update PAM to use faillock:
authconfig --enablefaillock --update

6 — System Maintenance

▶

6.1 File Permissions

▶
6.1.1 Ensure Permissions on /etc/passwd Are Configured (Automated)
L1 Auto
Description

This recommendation verifies that Permissions on /etc/passwd Are Configured on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
stat -c '%a %U %G' /etc/passwd
# Should return: 644 root root
Remediation
chmod 644 /etc/passwd
chown root:root /etc/passwd
6.1.2 Ensure Permissions on /etc/shadow Are Configured (Automated)
L1 Auto
Description

This recommendation verifies that Permissions on /etc/shadow Are Configured on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
stat -c '%a %U %G' /etc/shadow
# Should return: 0 root root
Remediation
chmod 0000 /etc/shadow
chown root:root /etc/shadow
6.1.3 Ensure No World-Writable Files Exist (Automated)
L1 Auto
Description

This recommendation verifies that No World-Writable Files Exist on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
find / -xdev -type f -perm -0002 -ls 2>/dev/null
# Should return empty — no world-writable files
Remediation
find / -xdev -type f -perm -0002 -exec chmod o-w {} \;

6.2 User & Group Settings

▶
6.2.1 Ensure No Accounts Have Empty Passwords (Automated)
L1 Auto
Description

This recommendation verifies that No Accounts Have Empty Passwords on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
awk -F: '($2 == "") {print $1}' /etc/shadow
# Should return empty
Remediation
awk -F: '($2 == "") {print $1}' /etc/shadow | while read user; do
  passwd -l "$user"
done
6.2.2 Ensure Root Is the Only UID 0 Account (Automated)
L1 Auto
Description

This recommendation verifies that Root Is the Only UID 0 Account on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
awk -F: '($3 == 0) {print $1}' /etc/passwd
# Should return only: root
Remediation
usermod -u <new_uid> <non_root_uid0_user>
6.2.3 Ensure All Users Home Directories Exist (Automated)
L1 Auto
Description

This recommendation verifies that All Users Home Directories Exist on the Amazon Linux 2 Linux operating system. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Amazon Linux 2 Linux operating system vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
awk -F: '($1 !~ /^(root|halt|sync|shutdown)$/ && $7 != "/sbin/nologin" && $7 != "/bin/false") {print $1":"$6}' /etc/passwd | \
  while IFS=: read user dir; do [ ! -d "$dir" ] && echo "Missing: $user -> $dir"; done
Remediation
mkhomedir_helper <username>
# Or:
mkdir -p /home/<username>
chown <username>:<group> /home/<username>
chmod 750 /home/<username>