5.2. 在 Microsoft Azure 上为安全引导配置 RHEL 实例


要确保 Azure 云平台上的 Red Hat Enterprise Linux (RHEL)实例有一个安全的操作系统引导过程,请使用安全引导。当注册自定义 RHEL Azure 镜像时,镜像由用于安全引导的预存储统一固件接口(UEFI)变量组成。这可让从 RHEL 镜像启动的所有实例第一次引导时都使用带有所需变量的安全引导机制。

Microsoft Azure 通过可信启动的 VM 支持安全启动。这些虚拟机提供安全机制来保护 rootkits 和 bootkits ,同时提供其他功能,如 Virtual Trusted Platform Manager (vTPM)。使用 GUI 创建实例时,您可以在 Configure security features 设置中找到 Enable secure boot 选项。

先决条件

  • 您已安装了这些软件包:

    • python3
    • openssl
    • efivar
    • keyutils
    • python3-virt-firmware
  • 您已安装了 azure-cli 工具。详情请参阅 在 Linux 上安装 Azure CLI

流程

  1. 使用 openssl 工具生成自定义证书 custom_db.cer

    $ openssl req -quiet \
    -newkey rsa:4096 \
    -nodes -keyout custom_db.key \
    -new -x509 \
    -sha256 -days 3650 \
    -subj "/CN=Signature Database key/" \
    --outform DER \
    -out custom_db.cer
    Copy to Clipboard Toggle word wrap
  2. 将证书转换为 base64 编码的格式:

    $ echo base64 -w0 custom_db.cer
    
    MIIFIjCCAwqgAwIBAgITNf23J4k0d8c0NR ....
    Copy to Clipboard Toggle word wrap
  3. 创建并编辑 azure-example-template.json Azure Resource Manager (ARM)文件,以注册新的 Azure Compute Gallery 镜像版本:

    $ vi azure-example-template.json
    
    {
        "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "resources": [
            {
                "type": "Microsoft.Compute/galleries/images/versions",
                "apiVersion": "2023-07-03",
                "name": "<your compute gallery/your image definition/version>",
                "location": "<location of the VHD>",
                "properties": {
                    "storageProfile": {
                        "osDiskImage": {
                            "source": {
                                "id": "<your-storage-account-id>",
                                "uri": "<url-with-the-vhd>"
                            },
                            "hostCaching": "ReadOnly"
                        }
                    },
                    "securityProfile": {
                        "uefiSettings": {
                            "signatureTemplateNames": [
                                "MicrosoftUefiCertificateAuthorityTemplate"
                            ],
                            "additionalSignatures": {
                                "db": [
                                    {
                                        "type": "x509",
                                        "value": [
                                            "<base64 of custom_db.cer>"
                                        ]
                                    }
                                ]
                            }
                        }
                    }
                }
            }
        ]
    }
    Copy to Clipboard Toggle word wrap
  4. 使用 azure-cli 工具注册镜像版本:

    $ az deployment group create --name <example_deployment> \
    --resource-group <example_resource_group> \
    --template-file <example_template.json>
    Copy to Clipboard Toggle word wrap
  5. 从 Azure 门户重启实例。

验证

  1. 检查新创建的 RHEL 实例是否启用了安全引导:

    $ mokutil --sb-state
    SecureBoot enabled
    Copy to Clipboard Toggle word wrap
  2. 使用 keyctl 工具验证自定义证书的内核 keyring :

    $ sudo keyctl list %:.platform
    
    keys in keyring:
    ...
    586621657: ---lswrv   0   0
    asymmetric: Signature Database key: f064979641c24e1b935e402bdbc3d5c4672a1acc
    ...
    Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat