7.11. 为测量的引导证明配置 Keylime
当您为测量的引导验证配置 Keylime 时,Keylime 会检查测量系统上的引导过程是否与您定义的状态相符。
前提条件
您有对配置了 Keylime 组件的系统的网络访问权限:
- 验证器
- 更多信息请参阅 第 7.2 节 “从软件包部署 Keylime 验证器”。
- 注册器
- 更多信息请参阅 第 7.4 节 “从软件包部署 Keylime 注册器”。
- 租户
- 更多信息请参阅 第 7.8 节 “从软件包部署 Keylime 租户”。
- Agent
- 更多信息请参阅 第 7.9 节 “从软件包部署 Keylime 代理”。
- 在代理系统上启用了统一可扩展固件接口(UEFI)。
流程
在配置并运行 Keylime 代理的受监控系统中,安装
python3-keylime软件包,其中包含keylime-policy工具:# dnf -y install python3-keylime在被监控的系统中,使用
keylime-policy工具从测量的系统当前状态的引导日志生成策略:# keylime-policy create measured-boot --eventlog-file /sys/kernel/security/tpm0/binary_bios_measurements --output <./measured_boot_reference_state.json>-
将
<./measured_boot_reference_state.json> 替换为keylime-policy保存生成的策略的路径。 如果您的 UEFI 系统没有启用安全引导,请传递
--without-secureboot参数。重要使用
keylime-policy生成的策略基于系统的当前状态,非常严格。任何系统修改,包括内核更新和系统更新都会更改引导过程,系统就会失败。
-
将
将生成的策略复制到配置了
keylime_tenant工具的系统上,例如:# scp root@<agent_ip>:<./measured_boot_reference_state.json> <./measured_boot_reference_state.json>在配置了 Keylime 租户的系统上,使用
keylime_tenant工具置备代理:# keylime_tenant --command add --targethost <agent_ip> --uuid <agent_uuid> --mb_refstate <./measured_boot_reference_state.json> --cert default-
将
<agent_ip>替换为代理的 IP 地址。 -
将
<agent_uuid>替换为代理的 UUID。 -
将
<./measured_boot_reference_state.json>替换为计算引导策略的路径。
如果您将测量的引导与运行时监控相结合,请在输入
keylime_tenant --command add命令时提供这两个用例中的所有选项。注意您可以使用
# keylime_tenant --command delete --targethost <agent_ ip>--uuid <agent_ uuid> ; 命令停止对节点监控进行 Keylime。您可以使用
keylime_tenant --command update命令修改已注册代理的配置。-
将
验证
重启被监控的系统,并验证代理是否成功:
# keylime_tenant --command cvstatus --uuid <agent_uuid> ... {"<agent.uuid>": {"operational_state": "Get Quote"..."attestation_count": 5 ...将
<agent_uuid>替换为代理的 UUID。如果
operational_state的值为Get Quote,并且attestation_count为非零,则此代理的证明成功。如果
operational_state的值为Invalid Quote或Failed,则验证失败,命令会显示类似如下的输出:{"<agent.uuid>": {"operational_state": "Invalid Quote", ... "ima.validation.ima-ng.not_in_allowlist", "attestation_count": 5, "last_received_quote": 1684150329, "last_successful_attestation": 1684150327}}如果验证失败,请在验证器日志中显示更多详细信息:
# journalctl -u keylime_verifier {"d432fbb3-d2f1-4a97-9ef7-75bd81c00000": {"operational_state": "Tenant Quote Failed", ... "last_event_id": "measured_boot.invalid_pcr_0", "attestation_count": 0, "last_received_quote": 1684487093, "last_successful_attestation": 0}}