5.4. 使用 Kickstart 执行 RHEL 的强化安装
要使您的系统符合特定安全配置文件,如 DISA STIG、CIS 或 ANSSI,您可以准备定义强化配置的 Kickstart 文件,使用定制文件自定义它,并运行强化系统的自动安装。
先决条件
-
openscap-scanner已安装在您的系统上。 -
scap-security-guide软件包安装在您的系统中,软件包版本与您要安装的 RHEL 版本对应。因为所有支持的 RHEL 版本都使用相同的 SCAP 安全指南版本,请在生成 Kickstart 文件前更新软件包。
流程
从数据流文件中找到安全配置文件的 ID:
$ oscap info /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml Profiles: … Title: Australian Cyber Security Centre (ACSC) Essential Eight Id: xccdf_org.ssgproject.content_profile_e8 Title: Health Insurance Portability and Accountability Act (HIPAA) Id: xccdf_org.ssgproject.content_profile_hipaa Title: PCI-DSS v3.2.1 Control Baseline for Red Hat Enterprise Linux 10 Id: xccdf_org.ssgproject.content_profile_pci-dss …-
可选:如果要使用 XCCDF 定制文件自定义强化,您可以使用
openscap-utils软件包提供的autotailor命令。如需更多信息,请参阅 使用 autotailor 自定义安全配置文件。 从 SCAP 源数据流生成 Kickstart 文件:
$ oscap xccdf generate fix --profile <profile_ID> --output <kickstart_file>.cfg --fix-type kickstart /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml+ 将
<profile_ID> 替换为系统应该遵守的配置集 ID,例如hipaa。+ 如果您使用定制文件,请使用-tailoring
-file tailoring.xml选项和自定义配置集 ID 将定制文件嵌入到生成的 Kickstart 文件中,例如:+
$ *oscap xccdf generate fix --tailoring-file tailoring.xml --profile _<custom_profile_ID>_ --output _<kickstart_file>_.cfg --fix-type kickstart ./ssg-rhel10-ds.xml*
进行检查,如果需要,手动修改生成的
<kickstart_file>.cfg,以适应您的部署需求。按照文件中的注释中的说明进行操作。注意有些更改可能会影响 Kickstart 文件安装的系统的合规性。例如,一些安全策略需要定义的分区或特定的软件包和服务。
- 使用 Kickstart 文件进行安装。要让安装程序使用 Kickstart,Kickstart 可以通过 web 服务器提供、在 PXE 中提供或嵌入到 ISO 镜像中。具体步骤请查看 自动安装 RHEL 文档中的 Semi-automated 安装:使 RHEL 安装程序可以使用的 Kickstart 文件 部分。
-
安装完成后,系统会自动重启。重启后,登录并查看保存在
/root目录中的安装 SCAP 报告。
验证
扫描系统的合规性,并将报告保存到 HTML 文件中以便查看:
使用原始配置文件:
# oscap xccdf eval --report report.html --profile <profile_ID> /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml使用定制配置文件:
# oscap xccdf eval --report report.html --tailoring-file tailoring.xml --profile <custom_profile_ID> /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml