5.2. Configuring a RHEL instance on the AWS Marketplace with Secure Boot
To ensure a secure booting process for a Red Hat Enterprise Linux (RHEL) instance on Amazon Web Services (AWS), configure Secure Boot on a RHEL instance. This instance is launched from a pre-configured Amazon Machine Image (AMI) from the AWS Marketplace.
Prerequisites
You have installed the following packages on the RHEL instance:
-
awscli2 -
python3 -
openssl -
efivar -
keyutils -
edk2-ovmf -
python3-virt-firmware
-
You have verified that the RHEL AMI has the
uefi-preferredoption enabled in boot settings:$ aws ec2 describe-images \ --image-id ami-0a951f007be151ff9 \ --region us-east-2 \ | grep -E '"ImageId"|"Name"|"BootMode"'"Name": "RHEL-10.1.0_HVM-20260217-x86_64-0-Hourly2-GP3", "BootMode": "uefi-preferred", "ImageId": "ami-0a951f007be151ff9",주의Store your private keys separately from the RHEL instance where you use them. If an intruder gains access to the instance, they could use the stored secrets to escalate their privileges and compromise your system security.
You have verified the platform status of the RHEL Marketplace AMI instance:
$ sudo mokutil --sb-stateSecureBoot disabled Platform is in Setup ModeThe
setupmode allows updating the Secure Boot UEFI variables within the instance.
Procedure
Generate a
custom_db.cercustom certificate:$ 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.cerGenerate UEFI variables file by using the
virt-fw-varsutility:$ virt-fw-vars --enroll-redhat \ --add-db-cert OvmfEnrollDefaultKeys custom_db.cer \ --set-dbx /usr/share/edk2/ovmf/DBX* \ --output-auth .For details, see the
virt-fw-vars(1)man page on your system.Convert Public Key (PK) variable to the Extensible Firmware Interface (EFI) Signature List (ESL) format:
$ tail -c +41 PK.auth > PK.esl참고Each GUID is an assigned value and represents an EFI parameter:
-
8be4df61-93ca-11d2-aa0d-00e098032b8c:EFI_GLOBAL_VARIABLE_GUID -
d719b2cb-3d3a-4596-a3bc-dad00e67656f:EFI_IMAGE_SECURITY_DATABASE_GUID
The
EFI_GLOBAL_VARIABLE_GUIDparameter maintains settings of the bootable devices and boot managers, while theEFI_IMAGE_SECURITY_DATABASE_GUIDparameter represents the image security database for Secure Boot variablesdb,dbx, and storage of required keys and certificates.-
Transfer the database certificates to the target instance, use the
efivarutility to manage UEFI environment variables.To transfer Key Exchange Key (
KEK.auth), enter:$ sudo efivar -w -A 0x67 -n 8be4df61-93ca-11d2-aa0d-00e098032b8c-KEK -f KEK.authTo transfer allowed signature database (
db.auth), enter:$ sudo efivar -w -A 0x67 -n d719b2cb-3d3a-4596-a3bc-dad00e67656f-db -f db.authTo transfer forbidden signature database (
dbx.auth) for x64 architecture, enter:$ sudo efivar -w -A 0x67 -n d719b2cb-3d3a-4596-a3bc-dad00e67656f-dbx -f dbx.authTo transfer
PK.esl, enter:$ sudo efivar -w -n 8be4df61-93ca-11d2-aa0d-00e098032b8c-PK -f PK.esl
- Reboot the instance from the AWS console.
Verification
Verify if Secure Boot is enabled:
$ 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