CentOS Stream 9 LVM
Overview
This guide covers deploying and configuring CentOS Stream 9 LVM on Microsoft Azure, using SecureAnyCloud's preconfigured virtual machine image from the Azure Marketplace.
CentOS Stream is the freely redistributable, community-developed upstream of Red Hat Enterprise Linux 9. It is a rolling release. Instead of pinning a minor version, it continuously tracks the packages that become the next RHEL 9 minor.
This image is the LVM variant. The root filesystem lives on a Logical Volume Manager logical volume rather than on a plain disk partition. LVM lets you grow the root filesystem online, add disks to the volume group and take snapshots, without repartitioning or downtime.
What you get:
- CentOS Stream 9, the community upstream of RHEL 9
- An LVM partitioned root: volume group
cs, logical volumeroot, formatted xfs - Every available Stream update applied at build time, with a verified zero-pending-updates check
- dnf-automatic armed, so the machine keeps applying security updates on its own
- Azure Linux Agent (waagent) and cloud-init for Azure integration
- Chronyd for NTP time synchronisation
- SELinux in enforcing mode
- BaseOS, AppStream and Extras repositories enabled, so your update path is intact
- Gen2 Hyper-V virtual machine support
- 24/7 SecureAnyCloud support
Platform: Microsoft Azure (Gen2 Hyper-V). Default user: azureuser.
Security posture
This image ships with no known credential. There is no default password and no baked-in SSH key:
- The root account password is locked, so no one can log in as root with a password.
PasswordAuthenticationis disabled in the SSH daemon, so every login is by key.PermitRootLoginis set tono, so root cannot be reached over SSH at all.- The only key that works is the public key you supply when you create the virtual machine. Azure injects it into
azureuserat first boot, so no two machines you launch ever share a secret. - The machine identity and the SSH host keys are regenerated uniquely on every instance, so no two machines share a host key either.
- SELinux is left in enforcing mode, the CentOS Stream default.
Prerequisites
Before you deploy this image, make sure you have:
- An active Microsoft Azure subscription
- Access to the Azure Portal or Azure CLI
- An SSH key pair for Linux VM access
- Familiarity with Azure VM management
Recommended VM Size: Standard_B2s (2 vCPU, 4 GB RAM) or larger.
Deploy the Virtual Machine
Option A: Azure Portal
- Go to the Azure Marketplace and search for "CentOS Stream 9 LVM SecureAnyCloud".
- Select the image and choose Create.
- On the Basics tab, set Subscription to your Azure subscription, Resource Group to a new or existing group, Virtual Machine Name to a name for your VM, Region to your preferred Azure region, and Size to
Standard_B2s(recommended). - Under Administrator Account, select SSH public key and enter your key.
- Under Inbound Port Rules, allow SSH (port 22).
- Choose Review + Create, then Create.
Option B: Azure CLI
az vm image terms accept --urn sac1647283583153:centos-stream-9-lvm:default:latest
az vm create \
--resource-group myResourceGroup \
--name my-centos-stream-9-lvm-vm \
--image sac1647283583153:centos-stream-9-lvm:default:latest \
--size Standard_B2s \
--admin-username azureuser \
--generate-ssh-keys \
--public-ip-sku StandardConnect via SSH
Run these commands on your own workstation, not on the VM. Find the public IP, then connect:
az vm show --resource-group myResourceGroup --name my-centos-stream-9-lvm-vm --show-details --query publicIps -o tsv ssh azureuser@<vm-ip>There is no password to enter. If SSH asks for one, your client is not offering the key you supplied at create time.
Confirm the release
Check that the machine is the CentOS Stream 9 release you expect:
cat /etc/centos-release grep -E '^(NAME|VERSION|ID|PLATFORM_ID)=' /etc/os-release uname -rmExpected output:
CentOS Stream release 9 NAME="CentOS Stream" VERSION="9" ID="centos" PLATFORM_ID="platform:el9" 5.14.0-731.el9.x86_64 x86_64The kernel version carries an el9 tag. CentOS Stream is a rolling release, so the exact kernel build advances as you apply updates. There is no fixed minor to pin to.
Verify the LVM root layout
This is the defining feature of this image. The root filesystem is a logical volume, not a plain partition. Confirm the layout:
lsblk -o NAME,TYPE,MOUNTPOINT,SIZE,FSTYPE findmnt /
sudo vgs
sudo lvsExpected output:
NAME TYPE MOUNTPOINT SIZE FSTYPE sda disk 10G ├─sda1 part /boot/efi 600M vfat ├─sda2 part /boot 1G xfs └─sda3 part 8.4G LVM2_member └─cs-root lvm / 8.4G xfs TARGET SOURCE FSTYPE OPTIONS / /dev/mapper/cs-root xfs rw,relatime,... VG #PV #LV #SN Attr VSize VFree cs 1 1 0 wz--n- 8.41g 0 LV VG Attr LSize root cs -wi-ao---- 8.41gRoot is /dev/mapper/cs-root, a logical volume in the cs volume group. The lvm type against / in lsblk proves that this is the LVM variant.
Growing the root filesystem
Because root is a logical volume, you can grow it online. First resize the OS disk in Azure: stop the VM, set a larger disk size, then start the VM. Then grow the partition, the physical volume, the logical volume and the xfs filesystem in sequence:
# grow partition 3 to fill the enlarged disk
sudo growpart /dev/sda 3
# grow the physical volume into the enlarged partition
sudo pvresize /dev/sda3
# extend the logical volume to use all free space in the volume group sudo lvextend -l +100%FREE /dev/cs/root
# grow the xfs filesystem to fill the enlarged logical volume (xfs grows mounted)
sudo xfs_growfs /You can also add a second data disk to the volume group and extend root across both. This is the main reason to run an LVM root:
sudo pvcreate /dev/sdc
sudo vgextend cs /dev/sdc
sudo lvextend -l +100%FREE /dev/cs/root
sudo xfs_growfs /Check the patch level
The image is fully updated at build time. dnf check-update returns exit code 100 when updates are pending and 0 when none are:
sudo dnf check-update echo "exit code: $?" dnf repolist --enabledThis image also arms dnf-automatic, so security updates are downloaded and applied on a timer without any action from you. You can still run updates on your own schedule:
sudo dnf upgrade -y sudo systemctl reboot
# only if a new kernel was installedVerify the security posture
Confirm that SELinux is enforcing, root is locked, and SSH accepts keys only:
getenforce
sudo passwd -S root
sudo sshd -T | grep -E '^(permitrootlogin|passwordauthentication|pubkeyauthentication)'Expected output:
Enforcing root LK 2009-12-22 -1 -1 -1 -1 (Password locked.) permitrootlogin no pubkeyauthentication yes passwordauthentication noVerify Azure integration and unattended updates
Confirm that the Azure Linux Agent, cloud-init and time synchronisation are healthy and that unattended security updates are armed. Then check your resources:
systemctl is-active waagent
systemctl is-enabled waagent cloud-init --version
systemctl is-enabled dnf-automatic.timer
systemctl is-active chronyd df -h / free -hwaagent is what lets Azure provision your SSH key, resize the OS disk, run extensions and report VM health. It should always be active and enabled.
An enabled dnf-automatic.timer is what keeps the machine applying security updates on its own after launch.
Networking and the firewall
The Azure Network Security Group is the control plane for inbound and outbound traffic. It is the first, and usually the only, place you need to open a port. The image advertises a single inbound port, SSH on 22.
This image binds no unnecessary listeners. rpcbind, the local RPC helper on port 111 that the stock cloud image leaves running, is disabled, because NFSv4, the CentOS Stream 9 default, does not use it. If you need NFSv3, restore it with one command:
sudo systemctl unmask rpcbind.socket
sudo systemctl enable --now rpcbind.socketConfirm what is listening before you open anything:
ss -tlnpOn a fresh machine, the only listener is sshd on port 22. If your policy also requires a host firewall, firewalld is installed and running with the SSH service already allowed:
sudo firewall-cmd --list-services sudo firewall-cmd --permanent --add-service=https sudo firewall-cmd --reloadInstall software
AppStream carries the application packages. Search it, then install what you need:
dnf search nginx
dnf module list nginx
sudo dnf install -y nginx
sudo systemctl enable --now nginxTo add another administrator, create the account with sudo adduser <name> and add it to the wheel group with sudo usermod -aG wheel <name>. Then copy your public key into /home/<name>/.ssh/authorized_keys. Give the file mode 600 and the .ssh directory mode 700, both owned by that user.
Common Use Cases
- RHEL 9-compatible application hosting where LVM-managed storage is a requirement
- Previewing and testing against the packages that become the next RHEL 9 minor
- Workloads that need to grow the root filesystem online without downtime
- Estates that add data disks to a machine over its lifetime and want them pooled under one filesystem
Troubleshooting
Cannot connect via SSH
- Verify the VM is in Running state in the Azure Portal
- Check that port 22 is allowed in the Network Security Group
- Ensure you are using the correct username:
azureuser - Verify your SSH key matches the one you supplied at create time. Password login is disabled by design, so a wrong key cannot fall back to a password prompt.
To see which key your client is offering, run ssh -v azureuser@<vm-ip> from your workstation and look for the Offering public key lines.
Azure agent not running
sudo systemctl status waagentIf it is not running, start it. Run this on the VM:
sudo systemctl enable --now waagentPackage manager issues
Refresh the metadata cache first:
sudo dnf clean all
sudo dnf makecacheIf repositories are unreachable, check DNS resolution with getent hosts mirror.stream.centos.org. Install bind-utils if you want dig and nslookup.
A service is blocked and the logs mention SELinux
SELinux is enforcing on this image. Instead of disabling it, look at what was denied:
sudo ausearch -m AVC -ts recent 2>/dev/null || echo "no recent AVC denials"Important Notes
CentOS Stream is free and open source. It is not covered by a single licence. It is a distribution assembled from thousands of independently packaged components, each carrying its own terms, including the GPL, LGPL, MIT, BSD, Apache 2.0 and MPL. Read every package's terms with rpm -qi <package> and under /usr/share/licenses/. No subscription, licence key or Red Hat entitlement is required.
CentOS Stream 9 receives full updates until 2027 and continuously tracks the next RHEL 9 minor. Applying updates keeps you current with the Stream.
CentOS is a trademark of Red Hat, Inc. The name is used here nominatively, only to identify the distribution this image contains. SecureAnyCloud is not affiliated with, endorsed by or sponsored by Red Hat or the CentOS project.
Support
For assistance with this image, contact SecureAnyCloud support:
- Website: secureanycloud.com
- Product catalogue: secureanycloud.com/products
- User Guides: secureanycloud.com/guides
- SLA: 24-hour response guaranteed
Deploy on Azure
Launch CentOS Stream 9 LVM on Azure with 24/7 support from SecureAnyCloud.
View on Marketplace
Need Help?
Our support team is available 24/7.
sales@secureanycloud.com
Overview
This guide covers launching and verifying the CentOS Stream 9 LVM AMI from SecureAnyCloud on Amazon EC2. It is one version of the SecureAnyCloud CentOS Stream listing on AWS Marketplace. You pick it as the software version when you subscribe and launch. Every release and variant in the listing is described at /guides/centos-stream-aws/.
CentOS Stream 9 is the free, community-built enterprise Linux distribution maintained by the CentOS Project. It is developed just ahead of Red Hat Enterprise Linux 9. It carries the fixes and features of the next RHEL 9 minor release before RHEL ships them, as a continuous stream of updates rather than numbered point releases.
This image starts from the official CentOS Stream 9 image for EC2 and adds four things:
- A hardened LVM disk layout. The root filesystem and six benchmark mount points are separate XFS logical volumes in the volume group
cs:/home,/tmp,/var,/var/tmp,/var/logand/var/log/audit. Each is mountednodev,nosuid, and/tmp,/var/tmp,/var/logand/var/log/auditare alsonoexec. A full log or temp volume cannot fill the root filesystem, and you can grow any volume on its own (Step 12). - CIS Level 1 Server remediation. The image is remediated with the OpenSCAP CIS Level 1 Server profile from SCAP Security Guide 0.1.82 (the CentOS Project's own signed
scap-security-guidepackage and its CentOS Stream 9 content), then rebooted and evaluated. Because the partitions are real, the benchmark's partition and mount option rules are applied and scored rather than waived. 272 of 273 scored rules pass (99.6%), the same on the build and on a freshly launched instance. Five rules are waived because they cannot work on an EC2 image, each with its reason. The HTML report, the machine-readable results, the waiver list and a summary are in/usr/share/doc/sac/. - 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 current AWS Systems Manager agent, and time from the Amazon Time Sync Service. - Fully patched at build time, with
dnf-automaticapplying all available updates on your instance every day. CentOS Stream publishes no separate security advisories, so there is no security-only update set to choose. Every update is applied.
The image includes CentOS Stream 9 (the 5.14 kernel), LVM2, cloud-init, OpenSSH, firewalld, chrony, tuned, SELinux (targeted policy, enforcing), the AWS Systems Manager agent, auditd, rsyslog, AIDE file integrity checking, dnf-automatic, OpenSCAP and the pinned SCAP Security Guide content used for the evaluation.
Default user: ec2-user. Architecture: x86_64. Boot mode: legacy BIOS. Root volume: 12 GiB gp3, one LVM physical volume holding seven XFS logical volumes.
These images are remediated with an OpenSCAP profile and ship their own evaluation report. They are not CIS Hardened Images, and CIS has not reviewed or certified them. CIS publishes no benchmark for CentOS Stream. The profile is the Red Hat Enterprise Linux 9 CIS content as packaged by the CentOS Project for CentOS Stream 9.
Connecting to your instance
Connect to CentOS Stream 9 LVM over SSH as the ec2-user user. The root device is /dev/xvda (12 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-useron first boot. - Key-only SSH.
PasswordAuthentication no,PermitRootLogin no, keyboard-interactive off and X11 forwarding off. The root account has no password and is locked. EC2 Instance Connect, which adds a second way to push SSH keys, is not installed. - 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 CentOS Stream ships it.
- Separate, restricted volumes. Temporary and log directories cannot hold device files, set-user-ID programs or executables, and filling one of them does not fill the root filesystem.
- Host firewall. firewalld's
publiczone 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
- An AWS account and permission to launch EC2 instances
- An EC2 key pair in the Region you launch in
- A security group that allows TCP 22 from your own address, not from the whole internet
Recommended instance type: m5.large. The image runs on any current x86_64 instance type.
Launch the instance
Option A: AWS Marketplace console
- Open the SecureAnyCloud CentOS Stream listing on AWS Marketplace. Choose View purchase options, then Subscribe. One subscription covers every version in the listing.
- Once the subscription is active, choose Launch your software.
- Choose One-click launch from AWS Marketplace, or Launch from EC2 Console for full control. In Version, choose CentOS Stream 9 LVM - YYYY-MM-DD, where the date is when the version was added, then choose your Region.
- Choose an instance type.
m5.largeis recommended, and any current x86_64 type works. The software charge is $0.04 per vCPU per hour. - Choose your EC2 key pair. It is the only way in. RSA and ED25519 keys both work.
- Set the security group to allow inbound TCP 22 from your own IP address or network only.
- Set the storage. The root volume is 12 GiB gp3 by default. You can choose a larger size. The extra space stays unallocated in the LVM physical volume until you give it to the volumes you choose (Step 12).
- Leave the metadata defaults, because 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. Replace the key pair, security group and subnet with your own. The root device of this AMI is /dev/xvda:
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/xvda,Ebs={VolumeSize=20,VolumeType=gp3}' \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=centos-stream-9-lvm}]'You do not need --metadata-options: the AMI already makes IMDSv2 required.
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>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 and running on this image.
Confirm the release
cat /etc/centos-release grep -E '^(NAME|VERSION|ID|VERSION_ID|PLATFORM_ID|PRETTY_NAME)=' /etc/os-release uname -srmExpected output:
CentOS Stream release 9 NAME="CentOS Stream" VERSION="9" ID="centos" VERSION_ID="9" PLATFORM_ID="platform:el9" PRETTY_NAME="CentOS Stream 9" Linux 5.14.0-758.el9.x86_64 x86_64CentOS Stream has no point releases. The release is just 9, and the system moves forward through ordinary dnf updates. Your kernel version is newer if updates have installed since this image was built.
See the LVM layout
The disk and its volumes:
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS /dev/nvme0n1Expected output with the default 12 GiB root volume:
NAME SIZE TYPE FSTYPE MOUNTPOINTS nvme0n1 12G disk ├─nvme0n1p1 1M part ├─nvme0n1p2 200M part vfat /boot/efi ├─nvme0n1p3 1G part xfs /boot └─nvme0n1p4 10.8G part LVM2_member ├─cs-root 4G lvm xfs / ├─cs-home 1G lvm xfs /home ├─cs-tmp 1G lvm xfs /tmp ├─cs-var 1.5G lvm xfs /var ├─cs-var_tmp 512M lvm xfs /var/tmp ├─cs-var_log 1G lvm xfs /var/log └─cs-var_log_audit 1G lvm xfs /var/log/auditThe volume group, its logical volumes and the mount options each volume carries:
sudo vgs
sudo lvs -o lv_name,lv_size,lv_path cs for m in / /home /tmp /var /var/tmp /var/log /var/log/audit /boot /dev/shm; do printf '%-15s %-36s %s\n' "$m" "$(findmnt -no SOURCE "$m")" "$(findmnt -no OPTIONS "$m" | tr , '\n' | grep -xE 'rw|ro|nodev|nosuid|noexec' | paste -sd, -)"; doneExpected output:
VG #PV #LV #SN Attr VSize VFree cs 1 7 0 wz--n- 10.80g 820.00m LV LSize Path home 1.00g /dev/cs/home root 4.00g /dev/cs/root tmp 1.00g /dev/cs/tmp var 1.50g /dev/cs/var var_log 1.00g /dev/cs/var_log var_log_audit 1.00g /dev/cs/var_log_audit var_tmp 512.00m /dev/cs/var_tmp / /dev/mapper/cs-root rw /home /dev/mapper/cs-home rw,nosuid,nodev /tmp /dev/mapper/cs-tmp rw,nosuid,nodev,noexec /var /dev/mapper/cs-var rw,nosuid,nodev /var/tmp /dev/mapper/cs-var_tmp rw,nosuid,nodev,noexec /var/log /dev/mapper/cs-var_log rw,nosuid,nodev,noexec /var/log/audit /dev/mapper/cs-var_log_audit rw,nosuid,nodev,noexec /boot /dev/nvme0n1p3 rw,nosuid,nodev /dev/shm tmpfs rw,nosuid,nodev,noexec- The disk has a 1 MiB BIOS boot partition, a 200 MiB EFI system partition, a 1 GiB
/boot(XFS) and one LVM physical volume. The AMI boots in legacy BIOS mode. The EFI partition is carried but not used to boot. It is mounted at/boot/efifrom/etc/fstab. - systemd also offers the same partition at
/efion demand, through an automount created bysystemd-gpt-auto-generator, as on every CentOS Stream 9 image. While that automount is active, for example in the first minutes after boot,lsblklists/efias a second mount point. - The mount options are set in
/etc/fstabby filesystem UUID, so they survive reboots and apply on every instance launched from the image. The last column shows the options that matter for the benchmark.findmntlists the rest. - The volume group keeps 820 MiB free at the default size, so you can grow the volume that fills first without touching EBS (Step 12).
The kernel finds its root filesystem on the logical volume. The same arguments are recorded in /etc/kernel/cmdline, so every kernel that a future update installs boots from the logical volume too:
grep -o 'root=[^ ]*\|rd.lvm[^ ]*' /proc/cmdline
grep -o 'root=[^ ]*\|rd.lvm[^ ]*' /etc/kernel/cmdline rpm -q lvm2 cloud-utils-growpart xfsprogsExpected output:
root=/dev/mapper/cs-root rd.lvm.lv=cs/root root=/dev/mapper/cs-root rd.lvm.lv=cs/root lvm2-2.03.33-6.el9.x86_64 cloud-utils-growpart-0.33-1.el9.x86_64 xfsprogs-6.4.0-9.el9.x86_64Read the compliance evidence
The evaluation the build ran after its reboot ships on the image:
ls -lh /usr/share/doc/sac/ python3 -c "import json; s=json.load(open('/usr/share/doc/sac/cis-l1-summary.json')); print('profile: ', s['profileLabel'], '(SCAP Security Guide', s['ssgVersion'] + ')'); print('scored rules: ', s['scored'], ' pass:', s['pass'], ' fail:', s['fail'], ' rate:', str(s['ratePct']) + '%'); print('waived: ', s['waived'], ' not applicable:', s['notapplicable']); print('evaluated at: ', s['evaluatedAt'])"Expected output:
total 39M -rw-r--r--. 1 root root 37M Oct 21 13:08 cis-l1-arf.xml -rw-r--r--. 1 root root 2.3M Oct 21 13:08 cis-l1-report.html -rw-r--r--. 1 root root 1.2K Oct 21 13:08 cis-l1-summary.json -rw-r--r--. 1 root root 1.5K Oct 21 13:08 cis-l1-tailoring.xml -rw-r--r--. 1 root root 2.0K Oct 21 13:08 cis-l1-waivers.txt -rw-r--r--. 1 root root 1.6K Oct 21 13:04 scap-security-guide-LICENSE.txt profile: CIS Level 1 Server (SCAP Security Guide 0.1.82) scored rules: 273 pass: 272 fail: 1 rate: 99.6% waived: 5 not applicable: 17 evaluated at: 2026-10-21T13:08:17Zcis-l1-report.htmlis the full OpenSCAP report, rule by rule. Copy it to your workstation and open it in a browser.cis-l1-arf.xmlis the same evaluation in the machine-readable ARF format, for compliance tooling.cis-l1-tailoring.xmlis the exact tailoring used, so you can re-run the same evaluation (Step 6).- The pass rate is pass / (pass + fail + error + unknown). Rules that are not applicable to this machine, not selected, or waived are not counted.
- Compared with the single-volume versions of this listing, the partition rules (
/tmp,/var,/var/tmp,/var/log,/var/log/auditand/homeon their own partitions, and their mount options) are scored here and pass.
To copy the report to your workstation, run this command on the workstation:
scp -i ~/.ssh/my-key-pair.pem ec2-user@<public-ip>:/usr/share/doc/sac/cis-l1-report.html .The five waived rules
grep -v '^#' /usr/share/doc/sac/cis-l1-waivers.txt | cut -f1,2Expected output:
grub2_password [serial-console-and-boot] ensure_root_password_configured [serial-console-and-boot] accounts_maximum_age_login_defs [key-only-account-aging] account_disable_post_pw_expiration [key-only-account-aging] sshd_limit_user_access [ssh-access-list]The full reason for each is the third column of the same file. In short:
- Boot loader and root passwords: a GRUB or root password would have to be baked into the image, giving every instance the same secret. Root stays locked with no password. Set your own if you need serial console access (see Step 11).
- Password ageing defaults: the accounts cloud-init creates are key-only. An ageing limit would expire them and lock the SSH key out. Accounts that do have a password are still aged.
- SSH AllowUsers/AllowGroups: a list fixed at build time would refuse accounts you create later. Your security group restricts who can reach port 22.
The one rule that does not pass
python3 -c "import json; [print(r) for r in json.load(open('/usr/share/doc/sac/cis-l1-summary.json'))['failingRules']]"Expected output:
ensure_journald_and_rsyslog_not_active_togetherjournald and rsyslog together. The benchmark wants one logging system, not both. CentOS Stream runs journald and rsyslog together by default. journald keeps the structured system journal (persistent, in /var/log/journal). rsyslog writes the traditional text logs (/var/log/messages, /var/log/secure, /var/log/cron) that many log shippers and audit procedures read.
The image keeps both, so neither kind of tooling loses its logs. If you standardise on one, for example the journal only, run sudo systemctl disable --now rsyslog on your instance and re-run Step 6.
Re-run the evaluation yourself
You can repeat the evaluation at any time with the same content and tailoring. It takes about a minute:
sudo oscap xccdf eval \
--tailoring-file /usr/share/doc/sac/cis-l1-tailoring.xml \
--profile xccdf_co.sac_profile_cis-l1_ec2_lvm \
--results /tmp/cis-check-results.xml --report /tmp/cis-check-report.html \
/usr/share/xml/scap/ssg/content/ssg-cs9-ds.xml > /tmp/cis-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/cis-check-results.xml').read())); s=sum(c[k] for k in ('pass','fail','error','unknown')); print(dict(sorted(c.items()))); print('pass rate: %.1f%%' % (100.0*c['pass']/s))"Expected output:
oscap exit code: 2 (2 = at least one rule did not pass) {'fail': 1, 'notapplicable': 17, 'notselected': 1250, 'pass': 272} pass rate: 99.6%Your own report is at /tmp/cis-check-report.html.
Use the ssg-cs9-ds.xml content shown above. The scap-security-guide package also ships ssg-rhel9-ds.xml, but that content applies only to Red Hat Enterprise Linux. On CentOS Stream it reports almost every rule as not applicable.
/tmp is noexec, which does not affect oscap, because it runs its check scripts through their interpreter. As you install software and change settings, re-run the evaluation to see how your changes affect the result.
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/regionExpected output (your Region may differ):
IMDSv1 request without a token: HTTP 401 us-east-1A 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.
The host firewall and listening ports
sudo firewall-cmd --state sudo firewall-cmd --list-all sudo ss -tlnpExpected output (the process IDs may differ):
running public (active) target: default icmp-block-inversion: no interfaces: eth0 sources: services: dhcpv6-client ssh ports: protocols: forward: yes masquerade: no forward-ports: source-ports: icmp-blocks: rich rules: 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=1277,fd=7)) LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=1277,fd=8))- Only
sshdlistens, on port 22. Nothing else on the image opens a TCP port. - The network interface is
eth0. The official CentOS Stream 9 image for EC2 boots withnet.ifnames=0, so the first interface keeps the traditional name. - The
publiczone allowssshanddhcpv6-client. The latter carries replies to the instance's IPv6 DHCP client, which is how an instance in an IPv6-enabled subnet gets its address. The CentOS defaultcockpitservice is removed from the zone, and Cockpit is not installed. - The loopback interface sits in firewalld's
trustedzone, with rules that drop traffic claiming a loopback source from anywhere else. This is a CIS requirement.
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 this on the instance:
sudo firewall-cmd --permanent --add-service=https sudo firewall-cmd --reloadIf a port is open in the security group but not in firewalld, or the other way round, the traffic does not arrive.
Time sync and the Systems Manager agent
systemctl is-active chronyd amazon-ssm-agent chronyc -n sourcesExpected output (the timings vary):
active active MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^* 169.254.169.123 3 4 37 5 -3572ns[ -128us] +/- 461usThe ^* marks 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.
The AWS Systems Manager agent is installed from Amazon's own package at its current release (3.3.5390.0 on this build). It is not in the CentOS Stream repositories, so dnf does not update it. Systems Manager can keep it current for you, through the AWS-UpdateSSMAgent document or the Auto update SSM Agent setting in Fleet Manager.
Patch level and automatic updates
The image is fully patched at build time. Check what is pending now and how automatic updates are set up:
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|reboot) =' /etc/dnf/automatic.conf systemctl is-enabled dnf-automatic.timer systemctl cat dnf-automatic.timer | grep -E '^(OnCalendar|RandomizedDelaySec)' uname -rExpected 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 = default apply_updates = yes reboot = never enabled OnCalendar=*-*-* 6:00 RandomizedDelaySec=60m 5.14.0-758.el9.x86_64dnf-automatic is configured on this image as follows:
upgrade_type = defaultinstalls every available update, not only security fixes. CentOS Stream's repositories carry no security advisory data, so a security-only setting would install nothing at all.apply_updates = yesinstalls the updates instead of only downloading them.- The timer runs daily at 06:00 (instance time, UTC by default) with a random delay of up to an hour.
reboot = nevermeans that a new kernel or core library is installed but takes effect only after you reboot, at a time you choose.
CentOS Stream moves ahead of RHEL and updates arrive continuously. If your workload is sensitive to package changes, test updates on a non-production instance first.
To stop automatic updates, run sudo systemctl disable --now dnf-automatic.timer. To update everything now, run:
sudo dnf -y upgradeReboot if a new kernel was installed:
sudo systemctl rebootA new kernel boots from the logical volume like the current one. Its boot entry is written to the /boot partition from /etc/kernel/cmdline (Step 4).
Security settings on the instance
getenforce
sudo passwd -S root
sudo sshd -T | grep -E '^(permitrootlogin|passwordauthentication|pubkeyauthentication|kbdinteractiveauthentication|x11forwarding|maxauthtries|clientaliveinterval|banner) ' cat /etc/issue.netExpected output:
Enforcing root LK 2024-02-07 0 99999 7 -1 (Alternate authentication scheme in use.) maxauthtries 4 clientaliveinterval 300 permitrootlogin no pubkeyauthentication yes passwordauthentication no kbdinteractiveauthentication no x11forwarding no banner /etc/issue.net Authorized users only. All activity may be monitored and reported.Enforcingmeans SELinux is on and enforcing the targeted policy. Keep it on. If your own software is denied, checksudo ausearch -m avc -ts recentinstead of disabling SELinux.LKin the second column means the root account is locked.sshd -Tprints the settings the SSH server actually uses, after every file in/etc/ssh/sshd_config.d/has been read.maxauthtries 4andclientaliveinterval 300come from the CIS profile. SSH allows four authentication attempts per connection and checks idle sessions every five minutes.- The banner text is shown before login.
- Password quality rules apply to root too (
enforce_for_root). A password that fails the quality checks is refused even when root sets it.
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:
sudo passwd ec2-userGrowing a volume, swap and file integrity
sudo vgs cs df -h / /var /var/log
sudo grep -E 'cc_growpart.py.*(SKIPPED|resized|NOCHANGE)' /var/log/cloud-init.log | tail -1 | cut -c1-150 swapon --noheadings --show | wc -l sudo grep -h aide /etc/crontabExpected output with the default 12 GiB root volume:
VG #PV #LV #SN Attr VSize VFree cs 1 7 0 wz--n- 10.80g 820.00m Filesystem Size Used Avail Use% Mounted on /dev/mapper/cs-root 4.0G 2.1G 2.0G 52% / /dev/mapper/cs-var 1.5G 169M 1.3G 12% /var /dev/mapper/cs-var_log 960M 56M 905M 6% /var/log 2026-10-21 13:31:29,980 - cc_growpart.py[DEBUG]: '/' SKIPPED: Resizing mapped device (/dev/mapper/cs-root) skipped as it is not encrypted. 0 05 4 * * * root /usr/sbin/aide --checkcloud-init does not grow LVM volumes. On a single-volume CentOS Stream image, cloud-init grows the root filesystem to the volume size on first boot. On this image the root filesystem is a logical volume, so cloud-init skips it (the SKIPPED line above). This is deliberate, because you decide which volume gets the space.
When you launch with a bigger root volume, or grow the EBS volume later with aws ec2 modify-volume, add the space in three steps on the instance:
- Grow partition 4 (the LVM physical volume) to the end of the disk, and tell LVM.
sudo growpart /dev/nvme0n1 4
sudo pvresize /dev/nvme0n1p4- Give space to the volumes that need it.
--resizefsgrows the XFS filesystem in the same step, online, with no reboot.
sudo lvextend --resizefs -L +4G /dev/cs/root
sudo lvextend --resizefs -L +2G /dev/cs/var- Check the result.
sudo vgs cs df -h / /varExample output after growing a 12 GiB volume to 20 GiB and running the commands above. The filesystem geometry that xfs_growfs prints is shortened to ...:
CHANGED: partition=4 start=2510848 old: size=22654943 end=25165790 new: size=39432159 end=41943006 Physical volume "/dev/nvme0n1p4" changed 1 physical volume(s) resized or updated / 0 physical volume(s) not resized File system xfs found on cs/root mounted at /. Size of logical volume cs/root changed from 4.00 GiB (1024 extents) to 8.00 GiB (2048 extents). Extending file system xfs to 8.00 GiB (8589934592 bytes) on cs/root... xfs_growfs /dev/cs/root ... data blocks changed from 1048576 to 2097152 xfs_growfs done Extended file system xfs on cs/root. Logical volume cs/root successfully resized. File system xfs found on cs/var mounted at /var. Size of logical volume cs/var changed from 1.50 GiB (384 extents) to 3.50 GiB (896 extents). Extending file system xfs to 3.50 GiB (3758096384 bytes) on cs/var... xfs_growfs /dev/cs/var ... data blocks changed from 393216 to 917504 xfs_growfs done Extended file system xfs on cs/var. Logical volume cs/var successfully resized. VG #PV #LV #SN Attr VSize VFree cs 1 7 0 wz--n- 18.80g 2.80g Filesystem Size Used Avail Use% Mounted on /dev/mapper/cs-root 8.0G 2.1G 5.9G 26% / /dev/mapper/cs-var 3.5G 130M 3.4G 4% /varThe new sizes persist across reboots. To give a volume all the remaining free space instead, use -l +100%FREE, for example sudo lvextend --resizefs -l +100%FREE /dev/cs/var_log.
Leaving some space unallocated is useful, because you can grow whichever volume fills first without touching EBS. XFS volumes grow online but cannot shrink, so add space in steps.
- Adding a data volume. Attach a new EBS volume, then give it its own volume group (for example
sudo pvcreate /dev/nvme1n1,sudo vgcreate datavg /dev/nvme1n1,sudo lvcreate -n data -l 100%FREE datavg,sudo mkfs.xfs /dev/datavg/data). Mount it from/etc/fstabby UUID with thenofailoption, so that the instance still boots if the volume is ever detached. Check the device name withlsblkfirst. On Nitro instances, the second EBS volume is usually/dev/nvme1n1. The image ships no LVM devices file (/etc/lvm/devices/system.devices), so LVM sees every attached disk. - Swap. The image has no swap. If your workload needs it, create a logical volume for it (for example
sudo lvcreate -L 512M -n swap cs, thensudo mkswap /dev/cs/swapand an/etc/fstabentry), or create a swap file on/or/var. - AIDE. The file integrity database is built from the image's own files. The CIS profile schedules
aide --checkdaily at 04:05 from/etc/crontab.
Install software and add users
The instance uses the standard CentOS Stream 9 repositories (BaseOS, AppStream and Extras):
sudo dnf -q list --available nginxExpected output (the version changes over time):
Available Packages nginx.x86_64 2:1.20.1-32.el9 appstreamInstall and start software in the usual way, for example sudo dnf -y install nginx then sudo systemctl enable --now nginx. Open its port in the security group and firewalld (Step 8).
Most software installs under /usr and /etc on the root volume and keeps its data and logs under /var. Watch the / and /var volumes as you add software, and grow them as needed (Step 12).
The CRB repository (build and development dependencies) is installed but disabled. Enable it with sudo dnf config-manager --set-enabled crb if a package needs it. The AWS CLI is not on the image. If you need it, install the current version from AWS (see the AWS CLI install guide).
To add another administrator, create the account, add it to the wheel group and give it an SSH key:
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/.sshBecause SSH is key-only, a new account needs its key in authorized_keys. restorecon gives the file the SELinux label that sshd expects.
The new account has no password, so sudo cannot authenticate it until you give it one with sudo passwd alice. SSH stays key-only, and sudo uses the password. Only ec2-user, created by cloud-init, has password-free sudo.
Common use cases
- A base for workloads that must show CIS Level 1 alignment on the RHEL 9 family, with the partition rules applied rather than waived and the evaluation report already on the machine
- Servers whose logs, temporary files or home directories must not be able to fill the root filesystem
- Developing and testing against what the next RHEL 9 minor release will contain, before it ships
- 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 6 and keep the report with your build
Troubleshooting
SSH says "Too many authentication failures"
The SSH server allows four authentication attempts per connection. If your SSH agent holds several keys, it can use them up 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>Cannot connect via SSH
- Check that the instance is running and has passed its status checks.
- Check the security group allows TCP 22 from your current public address.
- Use the user name
ec2-userand the key pair chosen at launch. Password login is disabled, so a wrong key never falls back to a password prompt. - If you changed firewalld, make sure the
sshservice is still allowed. Session Manager (Step 2) still works if SSH is blocked, provided that the instance has a Systems Manager instance profile.
I launched with a bigger volume but df shows the same size
This is expected on this image, because cloud-init does not grow logical volumes. Follow Step 12 to grow the physical volume and then the logical volumes you choose.
A volume is full
Check which one with df -h. If the volume group has free space (sudo vgs), grow the full volume with lvextend --resizefs (Step 12). If it does not, grow the EBS volume first with aws ec2 modify-volume or the console, then run the three steps in Step 12.
"Permission denied" running a script or binary
/tmp, /var/tmp, /var/log and /var/log/audit are mounted noexec. Run scripts through their interpreter (bash script.sh) or move them to your home directory or /opt.
My service is running but not reachable
Allow the port in both the security group and firewalld (Step 8). sudo firewall-cmd --list-all shows the firewalld rules, and 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. Then, for example, run 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 7), or use the AWS CLI or a current SDK.
An automatic update changed something
dnf-automatic applies every update daily (Step 10). See what changed and when with sudo dnf history list and sudo dnf history info <id>. sudo dnf history undo <id> reverses a transaction while the older packages are still in the repositories.
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, through a public IP or a NAT gateway, and that DNS resolves:
getent hosts mirrors.centos.orgImportant notes
CentOS Stream is free and open source software. 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 subscription or licence key is needed to run this 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/sac/scap-security-guide-LICENSE.txt).
The CentOS Project maintains CentOS Stream 9 until the end of Red Hat Enterprise Linux 9's full support phase, and it publishes the end-of-life date. For a longer runway on the same platform, the CentOS Stream 10 versions of this listing follow RHEL 10.
CentOS Stream is a continuously updated distribution that runs slightly ahead of RHEL 9, so it is not a drop-in replacement for a specific RHEL release.
The CIS Level 1 Server profile used here is the OpenSCAP profile published in SCAP Security Guide. These images are not CIS Hardened Images and are not certified by the Center for Internet Security. A pass rate measures this image as built. Your own changes affect it, which is why you can re-run the evaluation (Step 6).
CentOS is a trademark of Red Hat, Inc. Red Hat Enterprise Linux is a trademark of Red Hat, Inc. CIS is a trademark of the Center for Internet Security. These names are used only to identify the software, its compatibility and the profile. SecureAnyCloud is not affiliated with or endorsed by the CentOS Project, Red Hat or the Center for Internet Security.
Support
For help with this image, contact SecureAnyCloud support:
- Website: secureanycloud.com
- User Guides: secureanycloud.com/guides
- CentOS Stream on AWS hub: secureanycloud.com/guides/centos-stream-aws
Deploy on AWS
Launch CentOS Stream 9 LVM on AWS with 24/7 support from SecureAnyCloud.
View on Marketplace
Need Help?
Our support team is available 24/7.
sales@secureanycloud.com