目录
- 一、背景
- 二、问题分析
- 三、排查过程
- 四、修复方案
- 五、验证修复结果
- 六、自动化修复脚本
- 七、风险评估
- 八、总结
一、背景
在企业 Linux 安全基线扫描过程中,发现服务器存在如下基线告警:
Category: Business Use Notice Name: Business Use Notice MOTD/ISSUE Existence LINUX-MULTI Severity: Medium该检查项属于系统登录告警(Login Banner)类安全基线要求,主要用于提醒用户服务器属于企业资产,未经授权禁止访问,同时告知用户操作行为可能被监控和审计。
虽然该问题不会影响业务运行,但会导致:
- 安全基线检查不通过
- 生产环境合规检查失败
- 安全审计要求不满足
因此需要进行整改。
二、问题分析
Linux 系统通常通过以下两个文件向用户展示告警信息:
/etc/motd/etc/issue
其中:
/etc/motd—— 表示用户登录成功后显示的提示信息(Message Of The Day)/etc/issue—— 表示用户登录前显示的提示信息
安全基线通常要求上述文件存在,并包含企业规定的告警内容。
三、排查过程
首先选择已通过基线检查的标准服务器进行对比。
查看 MOTD:
cat/etc/motd发现内容如下:
----------------------Warning----------------------- Authorized access only This system is the property of Company Disconnect IMMEDIATELY if you are not an authorized user Your IP has been recorded. Do not damage any files! ----------------------------------------------------查看 ISSUE:
cat/etc/issue返回:
\S Kernel \r on \m说明标准环境中:
MOTD 存在企业告警信息 ISSUE 文件存在而问题服务器缺少对应内容,因此被安全扫描工具识别为:
Business Use Notice MOTD/ISSUE Existence不符合要求。
四、修复方案
4.1 配置登录后告警信息(MOTD)
编辑:
vi/etc/motd配置如下内容:
----------------------Warning----------------------- Authorized access only This system is the property of Company Disconnect IMMEDIATELY if you are not an authorized user Your IP has been recorded. Do not damage any files! ----------------------------------------------------4.2 配置登录前提示信息(ISSUE)
编辑:
vi/etc/issue配置:
\S Kernel \r on \m说明:
\S 代表系统名称 \r 代表内核版本 \m 代表硬件架构系统登录前会自动显示实际内容。
五、验证修复结果
验证 MOTD:
cat/etc/motd应显示:
----------------------Warning----------------------- Authorized access only This system is the property of Company Disconnect IMMEDIATELY if you are not an authorized user Your IP has been recorded. Do not damage any files! ----------------------------------------------------验证 ISSUE:
cat/etc/issue返回:
\S Kernel \r on \m检查文件存在:
ls-l/etc/motdls-l/etc/issue确认文件正常创建即可。
六、自动化修复脚本
对于多台服务器批量整改,可封装 Shell 脚本。
6.1 fix_motd_issue.sh
#!/bin/bashcat>/etc/motd<<'EOF' ----------------------Warning----------------------- Authorized access only This system is the property of Company Disconnect IMMEDIATELY if you are not an authorized user Your IP has been recorded. Do not damage any files! ---------------------------------------------------- EOFcat>/etc/issue<<'EOF' \S Kernel \r on \m EOFecho"========== /etc/motd =========="cat/etc/motdechoecho"========== /etc/issue =========="cat/etc/issue授权:
chmod+x fix_motd_issue.sh执行:
./fix_motd_issue.sh七、风险评估
本次整改仅涉及两个文本文件:
/etc/motd/etc/issue
不会影响:
- SSH 登录
- Web 服务
- 数据库服务
- 应用服务
- 网络配置
- 业务访问
无需执行reboot,无需执行systemctl restart sshd,修改后立即生效。
八、总结
本次问题属于 Linux 登录告警信息缺失导致的安全基线不符合项。通过补充/etc/motd和/etc/issue标准登录提示信息,即可满足:
Business Use Notice Business Use Notice MOTD/ISSUE Existence LINUX-MULTI检查要求。
该整改方案简单、安全、无业务影响,非常适合作为 Linux 安全基线标准化脚本的一部分进行批量实施。