隨著 Linux 在企業核心業務(Web、數據庫、中間件、容器平台)的大規模落地,作為基礎設施底座的 Linux 安全性直接決定業務系統的可信度。本文提煉企業級 Linux 服務器安全加固的十大核心要點,構建纵深防御體系。
pam_pwquality.so 要求 ≥12 位、大小寫+數字+特殊字符pam_google_authenticator.so 或 Duo SecurityPasswordAuthentication no、PubkeyAuthentication yesss -tulpn、systemctl list-units --type=service --state=runningpostfix、chronyd(若用 NTP)、avahi-daemon、cups 等127.0.0.1 或內網網段firewalld/nftables 白名單策略,拒絕默認auditd 審計子系統,規則覆蓋:身份認證、權限變更、文件完整性、網絡連接rsyslog + Logstash/Filebeat → Elasticsearch/Splunksu/sudo 異常、關鍵文件變更chattr +a /var/log/secure、遠程寫時唯一存儲www、mysql、redis)sudo 精細授權:/etc/sudoers.d/ 按角色分配命令白名單,拒絕 ALLawk -F: '$3==0' /etc/passwd 掃描 UID 0 賬號、sudo -l -U user 核對權限rsh/rlogin/rexec/rcp 等明文協議,chkconfig --del rsh 等PermitRootLogin no、Port 2222、MaxAuthTries 3、ClientAliveInterval 300、AllowUsers 白名單Defaults logfile=/var/log/sudo.log 獨立審計日誌Cmnd_Alias BACKUP = /usr/bin/rsync, /bin/tar%dba ALL=(ALL) NOPASSWD: BACKUP!/bin/bash, !/bin/sh, !/usr/bin/vim/bin、/sbin、/usr/bin、/etc、/lib、/bootnftables 微隔離/etc/sysctl.d/99-hardening.conf:
net.ipv4.tcp_syncookies=1
net.ipv4.conf.all.rp_filter=1
net.ipv4.conf.all.accept_redirects=0
kernel.kptr_restrict=2
kernel.dmesg_restrict=1
fs.protected_hardlinks=1
fs.protected_symlinks=1
dd if=/dev/sda of=/backup/forensic_$(date +%F).img安全非一次性項目,而是持續的生命週期管理。將上述十大要點納入 基線合規檢查清單,接入 CI/CD 流水線與 CMDB,實現「配置即代碼、合規即服務」,才能在攻防博弈中保持主動。