[步骤] Linux SCAP (Security Content Automation Protocol) 的生成 (Linux 开源安全报道的生成)

正文:

步骤一:安装 openscap 和相关组件

如果是 RHEL:

# yum install openscap openscap-scanner

如果是 SLE:

# zypper install openscap openscap-utils scap-security-guide

步骤二:下载最新的 SUSE 官方 OVAL 文件

2.1 进入存放下载的官方 OVAL 文件的目录

# cd /root

(补充:这里以把官方的 OVAL 文件下载到 /root 目录为例)

2.2 下载最新的官方 OVAL 文件

如果是 RHEL:

# wget -O - https://access.redhat.com/security/data/oval/v2/RHEL9/rhel-9.oval.xml.bz2

(补充:这里以下载 RHEL 9 官方的 OVAL 文件为例)

如果是 SLES:

# wget https://ftp.suse.com/pub/projects/security/oval/suse.linux.enterprise.15-patch.xml.bz2

(补充:这里以下载 SLE 15 官方的 OVAL 文件为例)

2.2 解压下载下来的 OVAL 文件

如果是 RHEL:

# bzip2 -d rhel-9.oval.xml.bz2

(补充:这里以解压 rhel-9.oval.xml.bz2 文件为例)

如果是 SLES:

# bzip2 -d suse.linux.enterprise.15-patch.xml.bz2

(补充:这里以解压 suse.linux.enterprise.15-patch.xml.bz2 文件为例)

步骤三:使用 SUSE 官方的 OVAL 文件生成 SCAP (Security Content Automation Protocol) 报告

如果是 RHEL:

# oscap oval eval  --report /root/rhel9.5_report20240101.html /root/rhel-9.oval.xml

(补充:这里以用刚刚下载的官方的 OVAL 文件生成名为 rhel9.5_report20240101.html 的 SCAP (Security Content Automation Protocol) 报告文件,并放在 /root 目录下为例)

如果是 SLES:

# oscap oval eval --report /root/sles15.5_report_20240101.html /root/suse.linux.enterprise.15-patch.xml

(补充:这里以用刚刚下载的官方的 OVAL 文件生成名为 sles15.5_report_20240101.html 的 SCAP (Security Content Automation Protocol) 报告文件,并放在 /root 目录下为例)

参考文献:

https://documentation.suse.com/compliance/all/html/SLES-openscap/index.html

[步骤] SLES 软件库的启用和禁用

注意:

在启用或禁用 SLES 的软件库前,要先注册此 SLES

正文:

步骤一:显示所有可用软件库

# SUSEConnect --list-extensions

步骤二:启用软件库

# SUSEConnect -p sle-module-live-patching/15.3/x86_64

(补充:这里以启用 sle-module-live-patching/15.3/x86_64 软件库为例)

步骤三:禁用软件库

# SUSEConnect -d -p sle-module-basesystem/15.3/x86_64

(补充:这里以禁用用 sle-module-live-patching/15.3/x86_64 软件库为例)

[步骤] SLES 到 SUSE 官网的注册和取消注册

正文:

步骤一:注册到 SLES 官网

# SUSEConnect -r <ActivationCode> -e <EmailAddress>

(补充:这里的 <ActivationCode> 和 <EmailAddress> 是在注册了 SUSE 账号并购买了对应的的订阅以后获得)

内容二:取消注册 SLES 到 SUSE 官网

2.1 取消注册 SLES 到 SUSE 官网

# SUSEConnect –de-register

或者:

# SUSEConnect -d

2.2 清空客户端与 SUSE 官网相关的缓存

# SUSEConnect --cleanup

2.3 删除客户端与 SUSE 官网相关的文件

# rm -f /etc/SUSEConnect
# rm -rf /etc/zypp/credentials.d/*
# rm -rf /etc/zypp/repos.d/*
# rm -f /etc/zypp/services.d/*

参考文献:

https://www.suse.com/support/kb/doc/?id=000018564

[步骤] 系统升级 (从 openSUSE Leap 15.4 升级到 openSUSE Leap 15.5)

步骤一:显示现在的系统版本

# cat /etc/*release*
NAME="openSUSE Leap"
VERSION="15.4"
ID="opensuse-leap"
ID_LIKE="suse opensuse"
VERSION_ID="15.4"
PRETTY_NAME="openSUSE Leap 15.4"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:leap:15.4"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"

(注意:确保显示的系统版本是 openSUSE Leap 15.4)

步骤二:准备升级

2.1 确认已使用的软件库

# zypper ls -d
#  | Alias                     | Name                               | Enabled | GPG Check | Refresh | Priority | Type   | URI
---+---------------------------+------------------------------------+---------+-----------+---------+----------+--------+---------------------------------------------------------------------------------------------
1  | repo-non-oss              | Non-OSS Repository                                           | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/distribution/leap/15.4/repo/non-oss/
2  | repo-oss                  | Main Repository                                              | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/distribution/leap/15.4/repo/oss/
3  | repo-update               | Main Update Repository                                       | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.4/oss/
4  | repo-update-non-oss       | Update Repository (Non-Oss)                                  | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.4/non-oss/
5  | repo-backports-update     | Update repository of openSUSE Backports                      | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.4/backports/
6  | repo-sle-update           | Update repository with updates from SUSE Linux Enterprise 15 | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.4/sle/


补充:
1) 确保以上软件库已处于 Enabled 状态
2) 手动启动这些软件库的命令如下

# zypper ar -fcg http://download.opensuse.org/distribution/leap/${releasever}/repo/non-oss/ Non-OSS Repository
# zypper ar -fcg http://download.opensuse.org/distribution/leap/${releasever}/repo/oss/ Main Repository
# zypper ar -fcg http://download.opensuse.org/update/leap/${releasever}/oss/ Main Update Repository
# zypper ar -fcg http://download.opensuse.org/update/leap/${releasever}/non-oss/ Update Repository (Non-Oss)
# zypper ar -fcg http://download.opensuse.org/update/leap/${releasever}/backports/ Update repository of openSUSE Backports
# zypper ar -fcg http://download.opensuse.org/update/leap/${releasever}/sle/ Update repository with updates from SUSE Linux Enterprise 15

3) 其中,Main Repository、Main Update Repository、Update repository of openSUSE Backports 和 Update repository with updates from SUSE Linux Enterprise 15 软件库是必须要有的,其他的软件库可以去掉

2.2 刷新已使用的软件库

# zypper ref

(注意:确保刷新成功,否则请检查网络)

2.3 将所有 openSUSE Leap 15.4 软件包更新到最新版本

# zypper -n update

2.4 用 releasever 变量替换所有版本号

# sed -i 's/15.4/${releasever}/g' /etc/zypp/repos.d/*.repo

步骤三:升级系统

3.1 将版本号设置为 15.5 并刷新

# zypper --releasever=15.5 refresh

3.2 提前下载并安装 openSUSE Leap 15.5 所需的软件包

# zypper --releasever=15.5 dup --download-in-advance

3.3 升级系统

# zypper --releasever=15.5 dup

3.4 重启系统

# reboot

步骤四:后续检查

4.1 显示升级后的系统版本

# cat /etc/*release*
NAME="openSUSE Leap"
VERSION="15.5"
ID="opensuse-leap"
ID_LIKE="suse opensuse"
VERSION_ID="15.5"
PRETTY_NAME="openSUSE Leap 15.5"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:leap:15.5"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"

4.2 显示升级后已使用的软件库

# zypper ls -d
#  | Alias                     | Name                                                         | Enabled | GPG Check | Refresh | Priority | Type   | URI
---+---------------------------+------------------------------------+---------+-----------+---------+----------+--------+---------------------------------------------------------------------------------------------
1  | repo-non-oss              | Non-OSS Repository                                           | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/distribution/leap/15.5/repo/non-oss/
2  | repo-oss                  | Main Repository                                              | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/distribution/leap/15.5/repo/oss/
3  | repo-update               | Main Update Repository                                       | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.5/oss/
4  | repo-update-non-oss       | Update Repository (Non-Oss)                                  | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.5/non-oss/
5  | repo-backports-update     | Update repository of openSUSE Backports                      | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.5/backports/
6  | repo-sle-update           | Update repository with updates from SUSE Linux Enterprise 15 | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.5/sle/

(补充:其中,Main Repository、Main Update Repository、Update repository of openSUSE Backports 和 Update repository with updates from SUSE Linux Enterprise 15 软件库是必须要有的,其他的软件库可以去掉)