在麒麟操作系统(Kylin OS)上进行系统安全加固和防护需要从多个层面进行综合配置。以下是详细的加固方案,分为基础加固、网络防护、权限控制、日志审计等关键环节:
系统更新与补丁管理
bash
sudo apt update && sudo apt upgrade -y # Ubuntu/Kylin版本
sudo yum update -y # CentOS/中标麒麟版本
bash
sudo apt install unattended-upgrades
sudo dpkg-reconfigure unattended-upgrades
最小化安装与服务管理
bash
sudo apt purge telnet rsh-server ftp # 示例:移除不安全协议
bash
sudo systemctl stop [service_name] # 如avahi-daemon
sudo systemctl disable [service_name]
内核参数调优
/etc/sysctl.conf
文件:
ini
net.ipv4.conf.all.rp_filter=1
net.ipv4.icmp_echo_ignore_broadcasts=1
kernel.kptr_restrict=2
bash
sudo sysctl -p
密码策略强化
/etc/login.defs
:
ini
PASS_MAX_DAYS 90
PASS_MIN_DAYS 7
PASS_WARN_AGE 14
libpam-pwquality
设置复杂度:
bash
sudo apt install libpam-pwquality
编辑 /etc/security/pwquality.conf
:
ini
minlen = 12
dcredit = -1
ucredit = -1
SSH安全配置
/etc/ssh/sshd_config
:
ini
PermitRootLogin no
PasswordAuthentication no # 强制密钥登录
MaxAuthTries 3
ClientAliveInterval 300
bash
sudo systemctl restart sshd
Sudo权限审计
bash
sudo visudo
添加:
ini
%admin ALL=(ALL) PASSWD: ALL
Defaults logfile=/var/log/sudo.log
防火墙配置(UFW/iptables)
bash
sudo ufw enable
sudo ufw default deny incoming
sudo ufw allow 22/tcp # 仅开放SSH
bash
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables-save > /etc/iptables.rules
入侵检测(IDS)
bash
sudo apt install suricata
sudo systemctl enable --now suricata
bash
sudo suricata-update
文件完整性监控
bash
sudo apt install aide
sudo aideinit
sudo mv /var/lib/aide/aide.db.new /var/lib/aide/aide.db
bash
sudo aide --check
日志集中管理
/etc/rsyslog.conf
:
ini
*.* @192.168.1.100:514
bash
sudo auditctl -w /etc/passwd -p wa -k passwd_changes
SELinux/AppArmor
bash
sudo systemctl enable apparmor
sudo aa-enforce /etc/apparmor.d/*
bash
sudo apparmor_status
容器安全
bash
docker run --cap-drop=ALL --read-only ...
OpenSCAP自动化审计
sudo apt install openscap-scanner
sudo oscap xccdf eval --profile stig ...
自定义脚本检查
bash
find / -perm -4000 -type f -exec ls -ld {} \;
/etc/ssh/sshd_config.bak
)。通过以上步骤,麒麟系统的安全等级可显著提升,满足等保2.0三级或CIS基准要求。实际实施时需根据具体业务需求调整策略。