5.2. 使用安全引导在 Azure 上配置 RHEL 虚拟机


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

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

Azure 平台上的安全引导

先决条件

  • 已安装这些软件包:

    • 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
  2. 将证书转换为 base64编码的格式:

    $ echo base64 -w0 custom_db.cer
    
    MIIFIjCCAwqgAwIBAgITNf23J4k0d8c0NR ....
  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>"
                                        ]
                                    }
                                ]
                            }
                        }
                    }
                }
            }
        ]
    }
  4. 使用 azure-cli 工具注册镜像版本:

    $ az deployment group create --name <example-deployment> \
    --resource-group <example-resource-group> \
    --template-file <example-template.json>
  5. 从 Azure 门户重启实例。

验证

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

    $ mokutil --sb-state
    SecureBoot enabled
  2. 使用 keyctl 工具验证自定义证书的内核密钥环:

    $ sudo keyctl list %:.platform
    
    keys in keyring:
    ...
    586621657: ---lswrv   0   0
    asymmetric: Signature Database key: f064979641c24e1b935e402bdbc3d5c4672a1acc
    ...
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2026 Red Hat
返回顶部