Bruce Schneier 名言:「安全是一個過程,而不是一個產品。」以下九條準則提煉自無數實戰經驗,構成 Linux 系統管理員的行為基線。
wheel/sudo 群組sudo 執行特權任務,留下審計軌跡 (/var/log/secure)rm -rf / 等毀滅性指令風險| 協定 | 動作 | 替代方案 |
|---|---|---|
| Telnet | 停用/移除 | SSH |
| FTP | 停用/移除 | SFTP (SSH 子系統) / FTPS (TLS) |
| RSH/Rlogin | 停用/移除 | SSH |
| SNMP v1/v2c | 停用 | SNMP v3 (加密+鑑別) |
PermitRootLogin no, PasswordAuthentication no, PubkeyAuthentication yes, Port 非 22, AllowUsers/AllowGroupsdistro-security-announce 郵件清單、CVE RSS、GitHub Security Advisoriesdnf-automatic/unattended-upgrades 僅套用 security 更新
# 掃描監聽埠
ss -ltnp | grep LISTEN
netstat -ltnp | grep LISTEN
# 典型應關閉服務 (視用途)
systemctl disable --now cups bluetooth avahi-daemon rpcbind nfs-server
# 僅在必要介面綁定
# /etc/ssh/sshd_config: ListenAddress 10.0.0.1
# /etc/my.cnf: bind-address = 127.0.0.1
# RPM (RHEL/Fedora/SUSE)
rpm --checksig package.rpm
# 導入廠商 GPG Key
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
# DEB (Debian/Ubuntu)
dpkg-sig --verify package.deb
apt-key list
gpgcheck=1 (yum/dnf) / APT::Get::AllowUnauthenticated falsecreaterepo_c --sign, dpkg-sig --signrsync, restic, borgbackup, Timeshift (系統快照), Velero (K8s)rsyslog/systemd-journald 結構化日誌Elastic Stack (ELK), Loki + Promtail, Graylog, Splunkawk '/Failed password/ {print $NF}' /var/log/secure | sort | uniq -c | sort -nrnftables (現代) / iptables / firewalld / ufw — 預設拒絕、最小開放/etc/hosts.allow, /etc/hosts.deny — 服務級存取控制 (支援 libwrap 的服務)ModSecurity (WAF), Fail2Ban (暴力破解), AppArmor/SELinux (MAC)九大鐵律環環相扣:最小權限 (1) → 加密通道 (2) → 修補漏洞 (3) → 縮小暴露 (4) → 供應鏈信任 (5) → 資料可恢復 (6) → 可見性 (7) → 多層阻隔 (8) → 持續感知 (9)。將其內化為日常操作習慣、自動化為 Ansible Playbook、固化為 CI/CD 門禁、審計為季度合規檢查,才能在攻防對抗中立於不敗之地。