5.3. Configuring a RHEL instance from a custom RHEL image with Secure Boot
To secure boot a Red Hat Enterprise Linux (RHEL) instance on Amazon Web Services (AWS), configure Secure Boot when registering a custom RHEL Amazon Machine Image (AMI). As this AMI consists of pre-stored UEFI variables, instances launched from it use the Secure Boot mechanism during the first boot.
Prerequisites
- You have created and uploaded an AWS AMI image. For details, see Preparing and uploading AWS AMI.
You have installed the following packages:
-
awscli2 -
python3 -
openssl -
efivar -
keyutils -
python3-virt-firmware
-
Procedure
Generate a custom certificate
custom_db.cer:$ openssl req -quiet \ -newkey rsa:3072 \ -nodes -keyout custom_db.key \ -new -x509 -sha256 \ -days 3650 -subj "/CN=Signature Database key/" \ --outform DER -out custom_db.cerUse the
virt-fw-varsutility to generate theaws_blob.binbinary file from keys, database certificates, and the UEFI variable store:$ virt-fw-vars --enroll-redhat \ --add-db-cert OvmfEnrollDefaultKeys custom_db.cer \ --set-dbx /usr/share/edk2/ovmf/DBX* \ --output-aws aws_blob.binThe customized blob consists of:
-
Public Key (
PK.cer), Key Exchange Key (KEK.cer), allowed signature database (db), and forbidden signature database (dbx) from theedk2-ovmfpackage -
custom_db.certhe generated certificate
-
Public Key (
Use the
awscli2utility to create and register the AMI from a disk snapshot with the required Secure Boot variables:$ aws ec2 register-image \ --name rhel-10.0-secure-boot \ --architecture x86_64 \ --virtualization-type hvm \ --root-device-name "/dev/sda1" \ --block-device-mappings "{\"DeviceName\": \"/dev/sda1\",\"Ebs\": {\"SnapshotId\": \"<snap-02d4db3813ff9b98e>\"}}" \ --ena-support --boot-mode uefi \ --region eu-central-1 \ --uefi-data $(cat aws_blob.bin) --output json{ "ImageId": "example-ami-id" }- Reboot the instance from the AWS Console.
Verification
Verify the Secure Boot functionality:
$ sudo mokutil --sb-stateSecureBoot enabledUse the
keyctlutility to verify the kernel keyring for the custom certificate:$ sudo keyctl list %:.platform7 keys in keyring: 741159788: ---lswrv 0 0 asymmetric: Microsoft Windows Production PCA 2011: a92902398e16c49778cd90f99e4f9ae17c55af53 941772267: ---lswrv 0 0 asymmetric: Red Hat Secure Boot CA 8: e1c6c580aa1e21d585aad9bf20f3929e5ec1f08b 979739129: ---lswrv 0 0 asymmetric: Red Hat Secure Boot CA 5: cc6fa5e72868ba494e939bbd680b9144769a9f8f 303712700: ---lswrv 0 0 asymmetric: Signature Database key: 7dff9c7433d40daa6cb2cdbdb4c2b7c93f5252a4 747313470: ---lswrv 0 0 asymmetric: Microsoft UEFI CA 2023: 81aa6b3244c935bce0d6628af39827421e32497d 710788326: ---lswrv 0 0 asymmetric: Microsoft Corporation UEFI CA 2011: 13adbf4309bd82709c8cd54f316ed522988a1bd4 163192: ---lswrv 0 0 asymmetric: Microsoft Corporation: Windows UEFI CA 2023: aefc5fbbbe055d8f8daa585473499417ab5a5272