Ho
Operating Systems AWS

Oracle Linux 9.8 STIG on AWS User Guide

| Product: Oracle Linux 9.8 STIG on AWS

Overview

This guide covers launching and verifying the Hardened Oracle Linux 9.8 STIG | cloudimg AMI on Amazon EC2, sold on AWS Marketplace as its own listing. The image starts from Oracle's own Oracle Linux 9.8 image for AWS (the VMDK Oracle publishes on yum.oracle.com, imported by cloudimg) on the Unbreakable Enterprise Kernel (UEK), and adds four things:

  • DISA STIG remediation. The image is remediated with the OpenSCAP DISA STIG profile for Oracle Linux 9 (xccdf_org.ssgproject.content_profile_stig, 488 rules) from SCAP Security Guide 0.1.82, using Oracle's own signed scap-security-guide package, then rebooted and evaluated. On this build 394 of 406 scored rules pass (97.0%). 26 rules are waived because they cannot work on an EC2 image or would need a secret or a value only you can know, each with its reason, and the 12 scored rules that do not pass are explained below. The HTML report, the machine-readable results, the tailoring, the waiver list and a summary ship in /usr/share/doc/cloudimg/.
  • The STIG's enforcement services. Application control (fapolicyd), USB device control (USBGuard, with USB storage disabled), auditd with the STIG's audit rules, AIDE file integrity checking, a shell idle timeout and account lockout after failed passwords.
  • EC2 defaults that keep you in control. Key-only SSH as ec2-user, root locked, no password on any account, SELinux enforcing, IMDSv2 required, a host firewall (firewalld) that allows SSH in and everything out, the AWS Systems Manager agent, and time from the Amazon Time Sync Service.
  • Fully patched at build time (no pending updates when the image was made), with dnf-automatic applying security updates on your instance.

Oracle Linux 9 is an enterprise Linux distribution from Oracle, binary compatible with Red Hat Enterprise Linux 9. Oracle Linux is openly licensed, so you need no Oracle licence and no Oracle subscription to run this image or to receive updates from Oracle's public yum server.

Pricing: $0.04 per vCPU per hour on every instance type (an m5.large has 2 vCPUs, so $0.08 per hour), plus AWS infrastructure charges.

What is on the image: Oracle Linux 9.8 with the Unbreakable Enterprise Kernel 6.12 (6.12.0-208.112.5.2.el9uek at build time), cloud-init 24.4, OpenSSH, firewalld, chrony, SELinux (targeted policy, enforcing), the AWS Systems Manager agent, auditd, rsyslog, fapolicyd, USBGuard, AIDE, dnf-automatic, OpenSCAP and the pinned SCAP Security Guide content used for the evaluation.

Default user: ec2-user. Architecture: x86_64. Root volume: 10 GiB gp3, XFS (grows to the size you choose at launch).

Licence: No Oracle licence and no Oracle subscription are needed to run this image or to receive updates from Oracle's public yum server. The software charge you see on AWS Marketplace is cloudimg's charge for the image.

A STIG is a configuration standard published by the US Defense Information Systems Agency (DISA). This image is remediated with the OpenSCAP DISA STIG profile and ships its own evaluation report. The pass rate is a measurement made with the SCAP Security Guide content; it is not a DISA certification or an authorisation to operate (ATO). DISA has not reviewed this image, and Oracle has not endorsed it. Step 15 lists what remains yours to do for your own authorisation.

Connecting to your instance

Version SSH user Root device
Oracle Linux 9.8 STIG ec2-user /dev/sda1 (10 GiB gp3)

Security posture

  • No known credential. There is no default password and no baked in SSH key. The only key that works is the EC2 key pair you choose at launch, which cloud-init installs for ec2-user on first boot.
  • Key-only SSH. PasswordAuthentication no, PermitRootLogin no. The root account has no password and is locked.
  • Per-instance identity. SSH host keys and the machine ID are generated fresh on every instance, so no two instances share a host key.
  • IMDSv2 required. The AMI is registered with ImdsSupport v2.0, so instances launched from it refuse token-less (IMDSv1) metadata requests by default.
  • SELinux enforcing with the targeted policy, as Oracle Linux ships it.
  • Application and device control. fapolicyd refuses to run executables that no RPM package installed; USBGuard controls which USB devices may attach.
  • Host firewall. firewalld's public zone allows only SSH and the DHCPv6 client inbound and allows all outbound traffic, so the SSM agent, metadata service, DNS, time and package updates keep working.
  • Only SSH listens on the network. Nothing else on the image listens on any address.

Prerequisites

  1. An AWS account and permission to launch EC2 instances
  2. An EC2 key pair in the Region you launch in
  3. A security group that allows TCP 22 from your own address (not from the whole internet)

Recommended instance type: m5.large. The software charge is $0.04 per vCPU per hour, the same rate on every instance type this listing offers, plus AWS infrastructure charges.

Step 1: Launch the instance

Option A: AWS Marketplace console

  1. Open the Hardened Oracle Linux 9.8 STIG | cloudimg listing on AWS Marketplace and choose View purchase options, then Subscribe.
  2. Once the subscription is active, choose Launch your software.
  3. Choose One-click launch from AWS Marketplace (or Launch from EC2 Console for full control), then in Version choose Oracle Linux 9.8 STIG (the version title may end with the date the version was added) and your Region.
  4. Instance type: m5.large is recommended; the software charge is $0.04 per vCPU per hour, the same rate on every instance type this listing offers, plus AWS infrastructure charges.
  5. Key pair: choose your EC2 key pair. It is the only way in. RSA and ED25519 keys both work (FIPS mode is not enabled, see Step 4).
  6. Security group: allow inbound TCP 22 from your own IP address or network only.
  7. Storage: the root volume is 10 GiB gp3 by default. Choose a larger size if you need one; cloud-init grows the root partition and filesystem to fill it on first boot. If your policy requires encryption at rest, set encryption on the volume here (see encrypt_partitions in Step 4).
  8. Metadata: leave the defaults. The image already requires IMDSv2. Then choose Launch.

Option B: AWS CLI

Run this on your own workstation. Replace the AMI ID with the one shown for your Region on the Marketplace launch page, and the key pair, security group and subnet with your own. The root device of this AMI is /dev/sda1:

aws ec2 run-instances \
  --image-id ami-0123456789abcdef0 \
  --instance-type m5.large \
  --key-name my-key-pair \
  --security-group-ids sg-0123456789abcdef0 \
  --subnet-id subnet-0123456789abcdef0 \
  --block-device-mappings 'DeviceName=/dev/sda1,Ebs={VolumeSize=20,VolumeType=gp3,Encrypted=true}' \
  --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=oracle-linux-9-8-stig}]'

You do not need --metadata-options: the AMI already makes IMDSv2 required.

When the instance is running, check its state, its public IP address and that IMDSv2 is required. Use the instance ID that run-instances printed (InstanceId):

aws ec2 describe-instances --instance-ids i-0123456789abcdef0 \
  --query 'Reservations[0].Instances[0].[State.Name,PublicIpAddress,MetadataOptions.HttpTokens]' --output text

Expected output (your public IP address differs):

running 203.0.113.25    required

HttpTokens is required, so the instance answers only IMDSv2 (token) metadata requests. Step 8 checks the same thing from inside the instance.

Step 2: Connect via SSH

From your workstation, connect as ec2-user with the key pair you chose:

ssh -i ~/.ssh/my-key-pair.pem ec2-user@<public-ip>

Before the login completes, SSH prints the Standard Mandatory DoD Notice and Consent Banner that the STIG requires (Step 11 shows how to replace it with your own organisation's notice). There is no password to enter. If SSH asks for one, or says Too many authentication failures, see Troubleshooting below.

You can also connect without opening port 22 at all through AWS Systems Manager Session Manager, if the instance has an instance profile that allows Systems Manager. The agent is installed, enabled and running on this image.

Check that first boot has finished

Once you are logged in, confirm cloud-init has finished its first-boot setup and no service has failed:

cloud-init status
systemctl is-system-running

Expected output:

status: done
running

If cloud-init still says status: running, wait a minute and run it again (cloud-init status --wait waits for it). If systemctl is-system-running prints degraded, a service has failed: systemctl --failed lists it.

Step 3: Confirm the release and kernel

cat /etc/oracle-release
grep -E '^(NAME|VERSION|ID|VERSION_ID|PLATFORM_ID|PRETTY_NAME)=' /etc/os-release
uname -srm
rpm -q kernel-uek

Expected output on an instance launched before any kernel update has installed:

Oracle Linux Server release 9.8
NAME="Oracle Linux Server"
VERSION="9.8"
ID="ol"
VERSION_ID="9.8"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Oracle Linux Server 9.8"
Linux 6.12.0-208.112.5.2.el9uek.x86_64 x86_64
kernel-uek-6.12.0-208.112.5.2.el9uek.x86_64

The image boots the Unbreakable Enterprise Kernel (UEK Release 8, kernel 6.12), the kernel Oracle uses in its own AWS images. The Red Hat Compatible Kernel is not installed.

The image is Oracle Linux 9.8 as built. Its repositories are Oracle's Oracle Linux 9 latest channels, which serve 9.8 today. Oracle publishes updates for the newest minor release, so when Oracle Linux 9.9 ships the instance moves to it through normal dnf updates, as every Oracle Linux 9 system does. Your kernel version is newer if updates have installed since this image was built.

Step 4: Read the compliance evidence

The evaluation the build ran after its reboot ships on the image:

ls -1 /usr/share/doc/cloudimg/
rpm -q scap-security-guide
python3 -c "import json; s=json.load(open('/usr/share/doc/cloudimg/stig-summary.json')); print('profile:      ', s['profileLabel'], '(SCAP Security Guide', s['ssgVersion'] + ')'); print('tailored id:  ', s['tailoredProfileId']); print('scored rules: ', s['scored'], ' pass:', s['pass'], ' fail:', s['fail'], ' errors:', s['error'], ' rate:', str(s['ratePct']) + '%'); print('waived:       ', s['waived'])"

Expected output:

scap-security-guide-LICENSE.txt
stig-arf.xml
stig-report.html
stig-summary.json
stig-tailoring.xml
stig-waivers.txt
scap-security-guide-0.1.82-2.0.1.el9_8.noarch
profile:       DISA STIG (SCAP Security Guide 0.1.82)
tailored id:   xccdf_co.cloudimg_profile_stig_ec2_single
scored rules:  406  pass: 394  fail: 12  errors: 0  rate: 97.0%
waived:        26
  • stig-report.html is the full OpenSCAP report, rule by rule. Copy it to your workstation and open it in a browser.
  • stig-arf.xml is the same evaluation in the machine-readable ARF format, for compliance tooling and for your own assessment records.
  • stig-tailoring.xml is the exact tailoring used (the 26 waived rules deselected from the DISA STIG profile), so you can re-run the same evaluation (Step 5).
  • stig-summary.json also records the evaluation time (evaluatedAt), the not applicable and not checked counts, and the data stream's checksum.
  • The pass rate is pass / (pass + fail + error + unknown). Rules that are not applicable to this machine, not selected, waived, or that need a manual check (not checked) are not counted. The build refuses an image that scores below 90%.

To copy the report to your workstation, run this on the workstation:

scp -i ~/.ssh/my-key-pair.pem ec2-user@<public-ip>:/usr/share/doc/cloudimg/stig-report.html .

The 26 waived rules

grep -v '^#' /usr/share/doc/cloudimg/stig-waivers.txt | cut -f1,2

Expected output:

sudo_remove_nopasswd    [default-user-sudo]
disallow_bypass_password_sudo   [default-user-sudo]
partition_for_tmp   [single-volume-partitions]
partition_for_home  [single-volume-partitions]
partition_for_var   [single-volume-partitions]
partition_for_var_log   [single-volume-partitions]
partition_for_var_log_audit [single-volume-partitions]
partition_for_var_tmp   [single-volume-partitions]
grub2_password  [serial-console-and-boot]
accounts_maximum_age_login_defs [key-only-account-aging]
account_disable_post_pw_expiration  [key-only-account-aging]
auditd_data_disk_full_action_stig   [audit-sizing-8gb]
auditd_data_disk_error_action_stig  [audit-sizing-8gb]
auditd_data_retention_admin_space_left_action   [audit-sizing-8gb]
auditd_data_retention_max_log_file_action_stig  [audit-sizing-8gb]
sysctl_crypto_fips_enabled  [fips]
configure_crypto_policy [fips]
enable_fips_mode    [fips]
enable_dracut_fips_module   [fips]
install_smartcard_packages  [smartcard]
package_opensc_installed    [smartcard]
sssd_enable_smartcards  [smartcard]
configure_opensc_card_drivers   [smartcard]
package_sssd_installed  [sssd-pki]
service_sssd_enabled    [sssd-pki]
rsyslog_remote_loghost  [syslog-remote-destination]

The full reason for each is the third column of the same file. In short:

  • Passwordless sudo for ec2-user (default-user-sudo): ec2-user has no password; cloud-init gives it password-free sudo. Removing NOPASSWD, or refusing it, would leave the only administrator unable to use sudo at all. Step 11 shows how to require a password for sudo safely once you have set one.
  • Separate partitions (single-volume-partitions): this image boots from one EBS root volume, so /tmp, /var, /var/log, /var/log/audit, /var/tmp and /home live on the root filesystem. (The reason text in the file also mentions cloudimg's LVM images; those are separate products.) If your assessor requires separate filesystems, add EBS volumes for them yourself (Step 15).
  • Boot loader password (serial-console-and-boot): a GRUB password would have to be baked into the image, giving every instance the same secret. Set your own if you need one (Step 15).
  • Password ageing defaults (key-only-account-aging): the accounts cloud-init creates are key-only. A default ageing limit would expire them and lock the SSH key out, so PASS_MAX_DAYS stays unlimited. Accounts that do have a password are still aged (the STIG's rule for existing passwords stays applied); set an age on new accounts with sudo chage -M 60 <user>.
  • Halt or single-user mode on audit storage problems (audit-sizing-8gb): on a single small root volume the audit log shares the disk with the operating system, so halting when the disk fills would take the whole instance down. auditd keeps its own rotate and suspend actions for those cases. Put /var/log/audit on its own volume if you need the STIG's actions.
  • FIPS mode (fips): FIPS mode is a separate, validated-module claim that needs the FIPS kernel setting and a reboot to be real, and the FIPS crypto policy refuses the ED25519 SSH keys that EC2 key pairs may use. FIPS mode is not enabled or claimed; the system-wide crypto policy is DEFAULT. Step 15 shows how to enable FIPS mode on your own instance if your authorisation needs it.
  • Smart cards (smartcard): EC2 instances have no smart-card readers, so the smart-card (CAC/PIV) packages and PAM settings would only add a login path nobody can use.
  • SSSD (sssd-pki): the DISA STIG content uses SSSD only as the client for DoD PKI smart-card logins against a directory. An EC2 image has no smart-card reader and joins no directory, and sssd.service exits at start-up with "No domain is enabled", so it would fail on every boot. SSSD is not installed. If you join a directory, install SSSD and configure it for your own domain and certificate authority.
  • Remote syslog server (syslog-remote-destination): the STIG forwards every syslog message to a remote log server, and the content fills in a placeholder host name (logcollector). An image cannot know your log server, and the placeholder would send every log message, authentication records included, to whichever host answers to that name in your network. rsyslog logs locally only; Step 11 shows how to forward to your own collector.

The 12 rules that do not pass

python3 -c "import json; [print(r) for r in json.load(open('/usr/share/doc/cloudimg/stig-summary.json'))['failingRules']]"

Expected output:

accounts_authorized_local_users
accounts_password_all_shadowed_sha512
aide_build_database
chronyd_configure_local_socket
encrypt_partitions
grub2_admin_username
harden_sshd_ciphers_opensshserver_conf_crypto_policy
harden_sshd_macs_opensshserver_conf_crypto_policy
network_configure_name_resolution
postfix_client_configure_mail_alias
selinux_context_elevation_for_sudo
sysctl_user_max_user_namespaces_no_remediation

None of these is hidden or remediated away. What each one means on this image:

  • accounts_authorized_local_users: the STIG wants every local account to be on a list your organisation approves (the var_accounts_authorized_local_users_regex value). The list is yours to define, so SCAP Security Guide ships no automatic fix, and the check flags accounts it does not know, such as ec2-user, which cloud-init creates.
  • accounts_password_all_shadowed_sha512: no account on the image has a password at all. Root is locked with no hash and ec2-user is key-only, and the check treats an account with no SHA-512 hash as failing. Any password you set is stored as SHA-512, which is what the image's login.defs and PAM settings use (Step 11).
  • aide_build_database: AIDE is installed, and its database is rebuilt from the image's own files as the last step of image preparation, after this evaluation ran; the check reads the database as it was at evaluation time. After you install software or change configuration, rebuild the database for your own instance (Step 13).
  • chronyd_configure_local_socket: the check wants chrony-wait.service rewritten to talk to chronyd over its local Unix socket. SCAP Security Guide 0.1.82 ships no automatic fix for it. chrony itself runs and uses the Amazon Time Sync Service (Step 10).
  • encrypt_partitions: in-guest LUKS encryption needs a passphrase at boot, which an unattended EC2 image cannot have. Encrypt the EBS volume instead (encryption at launch, or EBS encryption by default for your account), which encrypts the data at rest with AWS KMS.
  • grub2_admin_username: a boot-loader superuser only has an effect together with a boot-loader password, which would have to be baked into the image (the same reason grub2_password is waived). SCAP Security Guide ships no automatic fix. Set both together if you need them (Step 15).
  • harden_sshd_ciphers_opensshserver_conf_crypto_policy and harden_sshd_macs_opensshserver_conf_crypto_policy: these check the FIPS cipher and MAC lists in the crypto-policy back end for the SSH server. FIPS mode is not enabled (waived, above), so the system-wide DEFAULT crypto policy governs SSH (Step 11 shows the ciphers and MACs in effect).
  • network_configure_name_resolution: the check wants at least two name servers in /etc/resolv.conf. On EC2 the instance uses the Amazon-provided DNS resolver of its VPC, one address. If you run your own resolvers, configure them in the VPC's DHCP options set.
  • postfix_client_configure_mail_alias: root's mail should be forwarded to a monitored address, and only you know that address. Step 11 shows how to set it.
  • selinux_context_elevation_for_sudo: the STIG wants sudo to switch administrators into an SELinux administrator role. That needs a site-chosen administrators group mapped to an SELinux role in sudoers, which is a site decision; changing ec2-user's SELinux context on an image could break sudo for the only administrator. SCAP Security Guide ships no automatic fix.
  • sysctl_user_max_user_namespaces_no_remediation: the STIG wants user namespaces off (user.max_user_namespaces = 0). That breaks containers and some sandboxed software, so SCAP Security Guide deliberately ships no automatic fix. Set it yourself if you run no containers (Step 15).

The system trust store. The STIG also wants the system certificate trust store to hold only the US Department of Defense PKI root certificates (only_allow_dod_certs), and SCAP Security Guide ships no automatic fix for it. The image keeps Oracle Linux's standard trust store (ca-certificates) on purpose: replacing the public certificate authorities would break every TLS connection the instance makes outside DoD networks, including the Oracle Linux package repositories (so no updates), the SSM agent and the AWS APIs. A DoD system can install the DoD roots and remove the others itself.

Step 5: Re-run the evaluation yourself

You can repeat the evaluation at any time with the same content and tailoring. It takes a few minutes:

sudo oscap xccdf eval \
  --tailoring-file /usr/share/doc/cloudimg/stig-tailoring.xml \
  --profile xccdf_co.cloudimg_profile_stig_ec2_single \
  --results /tmp/stig-check-results.xml --report /tmp/stig-check-report.html \
  /usr/share/xml/scap/ssg/content/ssg-ol9-ds.xml > /tmp/stig-check.log 2>&1
echo "oscap exit code: $? (2 = at least one rule did not pass)"
sudo python3 -c "import re,collections; c=collections.Counter(re.findall(r'<result>(\w+)</result>', open('/tmp/stig-check-results.xml').read())); s=sum(c[k] for k in ('pass','fail','error','unknown')); print('pass:', c['pass'], ' fail:', c['fail'], ' error:', c['error'], ' unknown:', c['unknown']); print('pass rate: %.1f%%' % (100.0*c['pass']/s))"

The first line of the output is:

oscap exit code: 2 (2 = at least one rule did not pass)

The next two lines give your instance's counts and pass rate. Compare them with Step 4. A small difference on a new instance is expected, because some checks read state that changes after the build's evaluation; for example, the AIDE database exists on your instance, so aide_build_database can pass there.

Your own report is at /tmp/stig-check-report.html. The content file is ssg-ol9-ds.xml, the Oracle Linux 9 data stream; the RHEL 9 data stream that the same package carries reports every rule as not applicable on Oracle Linux. As you install software and change settings, re-run this to see how your changes affect the result. To evaluate against the complete, untailored DISA STIG profile (the waived rules included), run the same command with --profile xccdf_org.ssgproject.content_profile_stig and without --tailoring-file.

Step 6: Application control with fapolicyd

The STIG requires application control. On this image it is enforced by fapolicyd: every time a program is executed, fapolicyd checks the file against its trust database. Files installed by RPM packages (the Oracle Linux repositories, and anything else you install with dnf) are trusted automatically. An executable that arrived any other way, such as a copied, downloaded or compiled binary, is refused for ordinary users. Oracle Linux's own rule set lets root run trusted programs without restriction (allow perm=any uid=0 trust=1 : all), so the policy is aimed at non-root users; this image's test confirmed the refusal as ec2-user.

systemctl is-active fapolicyd
sudo grep -E '^(permissive|trust) ' /etc/fapolicyd/fapolicyd.conf
cp /usr/bin/date /tmp/my-date
/tmp/my-date || echo "exit code $?: fapolicyd refused to run /tmp/my-date (an untrusted copy)"
rm -f /tmp/my-date

The first line prints active. permissive = 0 means fapolicyd enforces its rules (with 1 it would only log what it would have denied), and trust = rpmdb,file means a file is trusted if the RPM database lists it or if it is in a trust file under /etc/fapolicyd/trust.d/. The copy of /usr/bin/date is byte-for-byte the same program, but it is not where an RPM put it, so running it fails with Operation not permitted and exit code 126.

cloudimg adds one systemd drop-in (/etc/systemd/system/fapolicyd.service.d/10-cloudimg-restart.conf) so that fapolicyd restarts by itself if it ever exits with an error, and application control comes back on its own.

Running your own software. Install it from an RPM package where you can: dnf updates the trust database for you. For software that arrives another way (a release tarball, a binary you build, an application under /opt), add it to a trust file and reload the trust database before you first run it:

sudo fapolicyd-cli --file add /opt/myapp/ --trust-file myapp
sudo fapolicyd-cli --update

If a program was already refused once, fapolicyd may still hold that decision; sudo systemctl restart fapolicyd clears it. After an upgrade of that software, run sudo fapolicyd-cli --file update /opt/myapp/ --trust-file myapp and sudo fapolicyd-cli --update again. Denials are logged in the audit log (sudo ausearch -m FANOTIFY -ts recent).

Step 7: USB devices and kernel hardening

systemctl is-active usbguard
grep -rh usb-storage /etc/modprobe.d/
sudo sysctl kernel.kexec_load_disabled kernel.yama.ptrace_scope kernel.unprivileged_bpf_disabled kernel.dmesg_restrict kernel.kptr_restrict net.core.bpf_jit_harden
grep -oE '(audit|audit_backlog_limit|page_poison|pti|slub_debug|vsyscall)=[^ ]*' /proc/cmdline
  • USBGuard is installed and enabled by the profile, with a policy generated from the devices present at build time and its decisions written to the Linux audit log. An EC2 instance has no USB bus, so any USB device that ever appeared would be outside that policy. The usb-storage kernel module is configured so that it cannot be loaded.
  • Kernel settings: kexec cannot load a new kernel at run time (kdump is disabled), only a parent process can ptrace its children, unprivileged users cannot load BPF programs, the BPF JIT is hardened, and kernel addresses and the kernel log are hidden from unprivileged users.
  • Boot options: freed memory is poisoned (page_poison), slab debugging is on, kernel page-table isolation is on, the legacy vsyscall page is off, and auditing starts at boot with a large backlog. Other kernel modules the STIG names (Bluetooth, FireWire, ATM, CAN, SCTP, TIPC, cramfs) are disabled the same way as USB storage.

Step 8: Confirm IMDSv2 is required

curl -s -o /dev/null -w 'IMDSv1 request without a token: HTTP %{http_code}\n' http://169.254.169.254/latest/meta-data/instance-id
TOKEN=$(curl -s -X PUT -H 'X-aws-ec2-metadata-token-ttl-seconds: 60' http://169.254.169.254/latest/api/token)
curl -s -H "X-aws-ec2-metadata-token: $TOKEN" -w '\n' http://169.254.169.254/latest/meta-data/placement/region

Expected output (your Region may differ):

IMDSv1 request without a token: HTTP 401
us-east-1

A request without a session token is refused with HTTP 401, and the same request with a token works. Scripts and SDKs on the instance must use IMDSv2; every current AWS SDK and the AWS CLI do this automatically.

Step 9: The host firewall and listening ports

sudo firewall-cmd --state
sudo firewall-cmd --get-default-zone
sudo firewall-cmd --list-services
sudo ss -tlnp

Expected output (the process ids differ):

running
public
dhcpv6-client ssh
State  Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0      128          0.0.0.0:22        0.0.0.0:*    users:(("sshd",pid=907,fd=7))
LISTEN 0      128             [::]:22           [::]:*    users:(("sshd",pid=907,fd=8))
  • Only sshd listens, on port 22. Nothing else on the image opens a TCP port.
  • The public zone allows ssh and dhcpv6-client (replies to the instance's IPv6 DHCP client, which is how an instance in an IPv6-enabled subnet gets its address). The default cockpit service is removed from the zone; Cockpit is not installed. No other port, rich rule or forward is open, and outbound traffic is not filtered.

Opening a port for your own service takes two steps: allow it in the instance's security group, and allow it in firewalld. For example, for a web server on 443, run on the instance:

sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

If a port is open in the security group but not in firewalld (or the other way round), the traffic will not arrive.

Step 10: Time sync and the Systems Manager agent

systemctl is-active chronyd amazon-ssm-agent
systemctl is-enabled amazon-ssm-agent
sudo chronyc -n sources
rpm -q amazon-ssm-agent

The first three lines print active, active and enabled. In the chronyc list, the line marked ^* is the source chrony is using: 169.254.169.123, the Amazon Time Sync Service. It is reachable from every instance without internet access, so time stays correct in a private subnet too; any public pool servers in the list are fallbacks.

The STIG makes chrony a client only (it serves time to nobody) and closes its network command port. chronyc therefore talks to chrony through its local socket, which needs root: run it with sudo. Without sudo it reports 506 Cannot talk to daemon.

The AWS Systems Manager agent is installed from Amazon's own package at the release that was current when the image was built. It is not in the Oracle Linux repositories, so dnf does not update it; Systems Manager can keep it current for you (the AWS-UpdateSSMAgent document, or the Auto update SSM Agent setting in Fleet Manager).

Step 11: STIG settings on the instance

getenforce
sudo passwd -S root
sudo sshd -T | grep -E '^(permitrootlogin|passwordauthentication|pubkeyauthentication|clientaliveinterval|clientalivecountmax|x11forwarding|banner|ciphers|macs) '
update-crypto-policies --show
grep -h '^[^#]*TMOUT' /etc/profile.d/*.sh
grep -vE '^\s*(#|$)' /etc/security/faillock.conf
grep -E '^(minlen|minclass|difok|dictcheck|enforce_for_root)' /etc/security/pwquality.conf
grep -E '^(UMASK|PASS_MIN_DAYS|PASS_MAX_DAYS|ENCRYPT_METHOD)' /etc/login.defs
sudo auditctl -s | grep -E '^(enabled|failure)'
sudo auditctl -l | wc -l
sudo grep -E '^(max_log_file|num_logs|space_left_action|admin_space_left_action|disk_full_action|disk_error_action) ' /etc/audit/auditd.conf

What to look for in the output:

  • getenforce prints Enforcing, and passwd -S root shows LK (the root account is locked).
  • sshd -T shows permitrootlogin no, passwordauthentication no, pubkeyauthentication yes, x11forwarding no and banner /etc/issue, with the idle-session settings the profile sets. The ciphers and macs lines are the ones the DEFAULT crypto policy allows.
  • update-crypto-policies --show prints DEFAULT (FIPS mode is waived, Step 4).
  • The TMOUT line, the faillock.conf lines and the pwquality.conf lines are the STIG's shell timeout, account lockout and password quality settings; enforce_for_root means the password rules apply to root too.
  • login.defs shows ENCRYPT_METHOD SHA512 and UMASK 077, with PASS_MAX_DAYS left unlimited (waived, Step 4).
  • auditctl -s shows enabled 2, which means the audit rules are locked until the next reboot; the line count is the number of audit rules loaded.

What these mean day to day:

  • SELinux is enforcing the targeted policy. Keep it on; if your own software is denied, check sudo ausearch -m avc -ts recent rather than disabling SELinux.
  • SSH. Root login and passwords are off and X11 forwarding is off. The server checks a silent connection after the idle interval the profile sets and drops it if the client does not answer.
  • Shell timeout. TMOUT is read-only, so an interactive shell left idle exits. Run long jobs under screen, nohup or a systemd unit rather than in an open terminal.
  • Account lockout. faillock locks an account, root included, after repeated wrong passwords, and keeps it locked until an administrator unlocks it (see Troubleshooting). This only affects password logins and sudo prompts; SSH is key-only.
  • Passwords you set must meet the STIG's length, character-class, difference and dictionary rules, and are stored as SHA-512.
  • New files. The default umask for new accounts is 077, so new home directories and files are private to their owner.
  • Audit. auditd runs with the STIG's audit rules (privileged commands, identity files, module loading, permission changes, logins and more), and the rules are immutable until the next reboot: changing them needs a reboot, which is itself recorded. auditd rotates its log, mails root when space runs low, and keeps its own suspend actions when the disk fills or fails (the halt actions are waived, Step 4).

The login banner. /etc/issue (shown by SSH before login) carries the Standard Mandatory DoD Notice and Consent Banner, which the STIG requires word for word on US Department of Defense systems. If your organisation is not a DoD system or uses its own notice, replace the text (the evaluation's banner_etc_issue rule then reports fail, which is expected for a non-DoD notice):

sudo cp /etc/issue /etc/issue.dod
echo "Authorized users only. All activity may be monitored and reported." | sudo tee /etc/issue

Sending logs off the instance. The STIG requires audit records and system logs to be kept off the machine. Where they go is your choice (CloudWatch Logs through the CloudWatch agent, a central syslog server, or audisp-remote), so the image sends nothing anywhere. The STIG's TLS settings for rsyslog forwarding are part of the profile (the gtls network stream driver, TLS required). To forward syslog to your own collector, add a file such as /etc/rsyslog.d/90-forward.conf containing *.* @@logs.example.internal:6514, point $DefaultNetstreamDriverCAFile at your collector's CA certificate, then run sudo systemctl restart rsyslog.

System mail. Root's mail (AIDE's reports and auditd's low-space warnings among it) should reach a monitored address that only you know. Set it in /etc/aliases and rebuild the alias database:

sudo sed -i '/^root:/d' /etc/aliases
echo "root: you@example.com" | sudo tee -a /etc/aliases
sudo newaliases

newaliases is provided by the mail server package; if rpm -q postfix reports it is not installed, install it with sudo dnf -y install postfix first. Where postfix is installed it listens on loopback only, and its TLS key is generated on each instance at first boot. Configure a relay host if you want the mail delivered off the instance.

Requiring a password for sudo. If your policy requires sudo authentication, first give each administrator a password (sudo passwd ec2-user; SSH stays key-only, the password is only used by sudo), confirm sudo -k; sudo true asks for it and works, and only then change NOPASSWD:ALL to ALL with sudo visudo -f /etc/sudoers.d/90-cloud-init-users. Doing it the other way round locks you out of sudo.

EC2 Serial Console and recovery. No account on this image has a password, so the serial console cannot log in until you set one. If you want serial console access, set a password for your own user on your running instance (the password is yours and is not on the image; it must meet the rules above):

sudo passwd ec2-user

Step 12: Patch level and automatic updates

The image is fully patched at build time. Check what is pending now:

sudo dnf -q check-update --refresh
echo "dnf check-update exit code: $? (0 = nothing to update, 100 = updates available)"
grep -E '^(upgrade_type|apply_updates)' /etc/dnf/automatic.conf
systemctl is-enabled dnf-automatic.timer
dnf repolist

Expected output on an instance launched soon after the image was built (later launches list the updates released since, with exit code 100):

dnf check-update exit code: 0 (0 = nothing to update, 100 = updates available)
upgrade_type = security
apply_updates = yes
enabled
repo id                repo name
ol9_UEKR8              Oracle Linux 9 UEK Release 8 (x86_64)
ol9_appstream          Oracle Linux 9 Application Stream Packages (x86_64)
ol9_baseos_latest      Oracle Linux 9 BaseOS Latest (x86_64)

The instance uses Oracle's public yum server (yum.oracle.com): BaseOS, AppStream and UEK Release 8. No subscription is needed. dnf-automatic runs daily and installs security updates automatically. Packages from the repositories stay trusted by fapolicyd after an update. To update everything now, run:

sudo dnf -y upgrade

Reboot if a new kernel was installed:

sudo systemctl reboot

Step 13: Disk size, swap and file integrity

df -hT /
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT
swapon --noheadings --show | wc -l
sudo ls -l /var/lib/aide/aide.db.gz

To see how far cloud-init grew the root partition on first boot, and the daily AIDE check:

sudo grep -E 'cc_growpart.*(resized|NOCHANGE)' /var/log/cloud-init.log | tail -1 | sed -E 's/.*resized: //'
sudo grep -h aide /etc/crontab

Expected output on an instance launched with a 20 GiB root volume (as in the Option B command in Step 1):

changed (/dev/nvme0n1p1) from 10736369664 to 21473771008
0 5 * * * root /usr/sbin/aide  --check | /bin/mail -s "$(hostname) - AIDE Integrity Check" root@localhost

The first line is cloud-init growing partition 1 from the image's 10 GiB to the 20 GiB volume at first boot. The second is the AIDE check the profile schedules in /etc/crontab: daily at 05:00, with the report mailed to root.

  • Disk layout. The root filesystem is XFS on partition 1, the only partition of the root volume; the instance boots in legacy BIOS mode. swapon prints 0: the image has no swap. Add a swap file yourself if your workload needs one.
  • Disk growth. cloud-init grows the root partition and filesystem to the volume size on first boot. To grow later, increase the EBS volume size in the console or with aws ec2 modify-volume, then run sudo growpart /dev/nvme0n1 1 && sudo xfs_growfs / (or reboot).
  • AIDE. The file integrity database at /var/lib/aide/aide.db.gz is built from the image's own files as the last step of image preparation, and the profile configures AIDE's scheduled check to notify root (see System mail in Step 11). After you install software or change configuration, rebuild it so later checks compare against your instance:
sudo aide --init && sudo mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
  • Audit log space. On the 10 GiB default, the audit log shares the root filesystem, so local audit history is short on a busy machine: forward the logs (Step 11), and launch with a larger root volume if you keep more locally.

Step 14: Install software and add users

The instance uses the standard Oracle Linux 9 repositories:

sudo dnf -q list --available nginx

The output lists the nginx packages the Oracle Linux 9 AppStream repository (ol9_appstream) offers; the versions change over time.

Install and start software in the usual way, for example sudo dnf -y install nginx then sudo systemctl enable --now nginx, and open its port in the security group and firewalld (Step 9). Software from RPM packages is trusted by fapolicyd automatically; anything else needs a trust entry (Step 6). Re-run the evaluation (Step 5) afterwards to see whether the new software changed the result. The AWS CLI is not on the image; install the current version from AWS (the AWS CLI install guide) and add it to fapolicyd's trust (sudo fapolicyd-cli --file add /usr/local/aws-cli/ --trust-file awscli, then sudo fapolicyd-cli --update).

To add another administrator, create the account, add it to the wheel group and give it an SSH key and a password:

sudo useradd -m -G wheel alice
sudo install -d -m 700 -o alice -g alice /home/alice/.ssh
echo "ssh-ed25519 AAAA... alice@laptop" | sudo tee /home/alice/.ssh/authorized_keys
sudo chown alice:alice /home/alice/.ssh/authorized_keys && sudo chmod 600 /home/alice/.ssh/authorized_keys
sudo restorecon -R /home/alice/.ssh
sudo passwd alice

Because SSH is key-only, a new account needs its key in authorized_keys (and restorecon gives the file the SELinux label sshd expects). The password you set with sudo passwd alice is what sudo asks for; the STIG makes sudo ask every time. If your policy ages passwords, set it per account, for example sudo chage -M 60 alice. Only ec2-user, created by cloud-init, has password-free sudo.

Step 15: What remains yours for an authorisation

The image gives you a remediated, evaluated starting point and the evidence for it. An authorisation to operate covers your whole system, so some STIG requirements can only be met by you, on your instance and in your AWS account:

  • Assess it yourself. Re-run the evaluation after your software is installed (Step 5), keep /tmp/stig-check-results.xml and the HTML report with your system documentation, and record your own decisions on the 12 failing and 26 waived rules (the reasons above are a starting point for your deviation records). For the full DISA checklist, compare against the current DISA STIG for Oracle Linux 9; rule-by-rule acceptance is your assessor's call.
  • FIPS mode, if your authorisation needs FIPS 140 validated cryptography: follow Oracle's documentation for FIPS mode on Oracle Linux 9 and the Unbreakable Enterprise Kernel (sudo fips-mode-setup --enable, reboot, then fips-mode-setup --check). The FIPS crypto policy refuses ED25519 SSH keys: make sure every account that logs in has an RSA or ECDSA key in authorized_keys before you reboot, or you will lock yourself out.
  • Encryption at rest: set Encrypted on the EBS volumes at launch or turn on EBS encryption by default for your account. EBS encryption is invisible to the operating system, so the in-guest encrypt_partitions check still reports its own result.
  • Boot loader password, if required: set one with sudo grub2-setpassword (the grub2_password rule), and rename the GRUB superuser from root in /etc/grub.d/01_users followed by sudo grub2-mkconfig -o /boot/grub2/grub.cfg (the grub2_admin_username rule). Keep the password in your vault, as it is needed to edit boot entries from the serial console.
  • Log and audit offloading to your collector, and a monitored mail alias for root (Step 11).
  • The login banner your organisation requires (Step 11), the list of authorised local accounts (accounts_authorized_local_users), the SELinux role mapping for administrators (selinux_context_elevation_for_sudo), and directory or smart-card authentication if you use them.
  • User namespaces: if nothing on the instance needs them (no containers), echo 'user.max_user_namespaces = 0' | sudo tee /etc/sysctl.d/90-userns.conf && sudo sysctl --system.
  • Separate volumes for /var, /var/log, /var/log/audit, /tmp, /var/tmp and /home, if your assessor requires them: attach EBS volumes and mount them with the options the STIG names.
  • DoD certificate trust store, if you are a DoD system: install the DoD PKI roots and remove the others (see The system trust store in Step 4).

Common use cases

  • A base for workloads that must show DISA STIG alignment on Oracle Linux 9, with the evaluation report already on the machine
  • Government, defence supply chain and regulated workloads that start from a STIG baseline instead of hardening by hand
  • Software built or packaged for Oracle Linux 9 or RHEL 9 compatible systems, on the Unbreakable Enterprise Kernel with SELinux and fapolicyd enforcing from the first boot
  • Fleets managed through Systems Manager, with IMDSv2 required from the first boot
  • A starting point for your own golden image: add your software, re-run Step 5, and keep the report with your build

Troubleshooting

SSH says "Too many authentication failures"

If your SSH agent holds several keys, it can use up the server's attempts before it offers the right one. Tell SSH to offer only the key you name:

ssh -o IdentitiesOnly=yes -i ~/.ssh/my-key-pair.pem ec2-user@<public-ip>

SSH or the shell disconnects when idle

That is the STIG's shell timeout: an interactive shell left idle exits (TMOUT, read-only). Run long jobs under screen or nohup, or as a systemd unit. If the connection itself drops while you are idle, a network device between you and the instance is closing quiet connections; a client-side keep-alive helps (ssh -o ServerAliveInterval=60 ...).

A program fails with "Operation not permitted"

That is fapolicyd refusing an executable that no RPM package installed. Check the audit log:

sudo ausearch -m FANOTIFY -ts recent

Install the software from a package, or add it to a trust file and restart fapolicyd (Step 6). Do not disable fapolicyd to work around it: application control is a STIG requirement, and turning it off fails the evaluation.

Cannot connect via SSH

  1. Check the instance is running and has passed its status checks.
  2. Check the security group allows TCP 22 from your current public address.
  3. Use the user name ec2-user (not opc, the user of Oracle's OCI images) and the key pair chosen at launch. Password login is disabled, so a wrong key never falls back to a password prompt.
  4. If you enabled FIPS mode, ED25519 keys are refused; use an RSA or ECDSA key.
  5. If you changed firewalld, make sure the ssh service is still allowed. Session Manager (Step 2) still works if SSH is blocked, provided the instance has a Systems Manager instance profile.

An account is locked after wrong passwords

faillock keeps an account locked after repeated failures until an administrator clears it. From ec2-user (or Session Manager), check and reset it:

sudo faillock --user alice
sudo faillock --user alice --reset

chronyc says "506 Cannot talk to daemon"

The STIG closes chrony's network command port. Run chronyc with sudo so it uses the local socket (Step 10).

My service is running but not reachable

Allow the port in both the security group and firewalld (Step 9). sudo firewall-cmd --list-all shows the firewalld rules; sudo ss -tlnp shows whether the service listens on all addresses or only on loopback. If the service runs on a non-standard port, SELinux may also need to allow it: install the SELinux management tools with sudo dnf -y install policycoreutils-python-utils if semanage is missing, then, for example, sudo semanage port -a -t http_port_t -p tcp 8080 for a web server on 8080.

A tool that uses instance metadata fails

The image requires IMDSv2. Old scripts that call http://169.254.169.254/ without a token get HTTP 401. Update them to request a token first (Step 8), or use the AWS CLI or a current SDK.

Package manager issues

Refresh the metadata first:

sudo dnf -q makecache --refresh && echo "repository metadata refreshed"

If the repositories are unreachable, check that the instance has outbound internet access (a public IP or a NAT gateway) and that DNS resolves:

getent hosts yum.oracle.com

Important notes

Oracle Linux is open source software that anyone may use and redistribute. It is a distribution of thousands of packages, each under its own licence (GPL, LGPL, MIT, BSD, Apache 2.0 and others); rpm -qi <package> shows each package's licence. No Oracle licence, subscription or licence key is needed to run this image or to receive updates from Oracle's public yum server; the software charge on AWS Marketplace is cloudimg's. Oracle Linux Support is a separate, optional subscription from Oracle; this image does not include it, and Ksplice and the OCI agent are not on the image. The compliance tooling is OpenSCAP (LGPL 2.1 or later) and SCAP Security Guide content (BSD 3-Clause, licence text in /usr/share/doc/cloudimg/scap-security-guide-LICENSE.txt).

This version is Oracle Linux 9.8 as built and tracks the Oracle Linux 9 release stream, so new minor releases (9.9 and on) and UEK builds arrive as ordinary updates.

The DISA STIG profile used here is the OpenSCAP profile for Oracle Linux 9 published in SCAP Security Guide 0.1.82, from Oracle's own scap-security-guide package. The pass rate (394 of 406 scored rules, 97.0%) is a measurement of this image as built, made with that content; it is not a DISA certification or an authorisation to operate, and DISA has not reviewed this image. Your own changes affect the result, which is why the evaluation can be re-run (Step 5), and some STIG requirements are about how you operate the system (Step 15).

Oracle and Oracle Linux are registered trademarks of Oracle and/or its affiliates. Red Hat Enterprise Linux is a trademark of Red Hat, Inc. These names are used only to identify the software, its compatibility and the profile. cloudimg is not affiliated with or endorsed by Oracle, Red Hat, the Defense Information Systems Agency or the US Department of Defense.

Support

cloudimg's support team is on hand 24 hours a day by email for this image, with a guaranteed response within 24 hours: launch and first login, SSH and firewalld, SELinux, fapolicyd and USBGuard, dnf updates, the STIG report and troubleshooting.