6.11. 为测量的引导证明配置 Keylime
当您为测量的引导验证配置 Keylime 时,Keylime 会检查测量系统上的引导过程是否与您定义的状态相符。
先决条件
您有对配置了 Keylime 组件的系统的网络访问权限:
- 验证器
- 如需更多信息,请参阅从 软件包部署 Keylime verifier。
- 注册器
- 如需更多信息,请参阅从 软件包 部署 Keylime 注册中心。
- 租户
- 如需更多信息,请参阅从 软件包 部署 Keylime 租户。
- Agent
- 如需更多信息,请参阅从 软件包 部署 Keylime 代理。
- 在代理系统上启用了统一可扩展固件接口(UEFI)。
流程
在配置并运行 Keylime 代理的受监控系统中,安装
python3-keylime
软件包,其中包含keylime-policy
工具:dnf -y install python3-keylime
# dnf -y install python3-keylime
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 在被监控的系统中,使用
keylime-policy
工具从测量的系统当前状态的引导日志生成策略:keylime-policy create measured-boot --eventlog-file /sys/kernel/security/tpm0/binary_bios_measurements --output <./measured_boot_reference_state.json>
# keylime-policy create measured-boot --eventlog-file /sys/kernel/security/tpm0/binary_bios_measurements --output <./measured_boot_reference_state.json>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
将
<./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>
# scp root@<agent_ip>:<./measured_boot_reference_state.json> <./measured_boot_reference_state.json>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 在配置了 Keylime 租户的系统上,使用
keylime_tenant
工具置备代理:keylime_tenant --command add --targethost <agent_ip> --uuid <agent_uuid> --mb_refstate <./measured_boot_reference_state.json> --cert default
# keylime_tenant --command add --targethost <agent_ip> --uuid <agent_uuid> --mb_refstate <./measured_boot_reference_state.json> --cert default
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
将
<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>
# keylime_tenant --command cvstatus --uuid <agent_uuid> ... {"<agent_uuid>": {"operational_state": "Get Quote"..."attestation_count": 5 ...
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 将
<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}}
{"<agent_uuid>": {"operational_state": "Invalid Quote", ... "ima.validation.ima-ng.not_in_allowlist", "attestation_count": 5, "last_received_quote": 1684150329, "last_successful_attestation": 1684150327}}
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 如果验证失败,请在验证器日志中显示更多详细信息:
journalctl -u keylime_verifier
# 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}}
Copy to Clipboard Copied! Toggle word wrap Toggle overflow