OpenSCAP ssh 与密钥文件

OpenSCAP ssh 与密钥文件

我想在我的 Windows PC 上运行 OpenSCAP 来测试 CentOS 系统。问题是,根据公司政策,我只能使用密钥文件通过 ssh 连接到 CentOS。我没有找到 SCAP 工作台是否支持此功能。可以这样做吗?还是我需要 ssh 密码?

答案1

至少在 scap-workbench 1.2.1 上,您可以使用Dry runtoggled 运行扫描,这将为您提供要执行扫描的命令行。使用此命令行,您可以使用 oscap-ssh 帮助中所示的变量覆盖 ssh 选项:

To supply additional options to ssh/scp, define the SSH_ADDITIONAL_OPTIONS variable For instance, to ignore known hosts records, define SSH_ADDITIONAL_OPTIONS='-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'

从 ssh 选项中,您可以使用该选项-i identity_file提供您想要用于身份验证的私钥的文件路径。

最后你会得到类似这样的结果:

$ export SSH_ADDITIONAL_OPTIONS='-i /path/to/private/key'

$ oscap-ssh [email protected] 22 xccdf eval --datastream-id scap_org.open-scap_datastream_from_xccdf_ssg-fedora-xccdf-1.2.xml --xccdf-id scap_org.open-scap_cref_ssg-fedora-xccdf-1.2.xml --profile xccdf_org.ssgproject.content_profile_ospp --oval-results --results /tmp/xccdf-results.xml --results-arf /tmp/arf.xml --report /tmp/report.html /tmp/scap-workbench-XDOICh/ssg-fedora-ds.xml

答案2

可能已经很晚了,但我也遇到了同样的问题,所以我只是将我的密钥添加到 ssh-agent,这样我就不需要为 ssh 命令指定密钥了……在我的 Mac 上,我刚刚使用命令检查了代理ssh-agent,它显示它正在运行,然后我用来ssh-add <path-to-key-file>添加密钥(添加后,您可以运行ssh-add -l以列出他们添加的密钥)。下次当您运行工作台时,它会自动尝试将添加的密钥通过 ssh 连接到远程实例。

相关内容