承接前篇,本文聚焦 NFS 限制、關鍵檔案權限收斂、遠端日誌部署、SSH/SCP 加密傳輸、系統快照與主機型入侵偵測(HIDS)等進階防護措施。
/etc/exports,預先定義允許共享目錄,禁止使用者任意匯出。/etc/init.d/nfs 中 daemon rpc.nfsd 行以停用伺服端功能。採用 chmod 收斂權限,chattr +i 賦予不可變屬性(防刪改),chattr +a 限制日誌僅能追加:
chmod 700 /bin/rpm
chmod 600 /etc/exports /etc/hosts.* /etc/shadow /etc/lilo.conf /etc/securetty /etc/ftpusers /etc/xinetd.conf /etc/inetd.conf /etc/crontab
chmod 644 /etc/passwd /var/log/messages /var/log/lastlog
chmod 750 /etc/pam.d /etc/ssh /etc/security /etc/rc.d/init.d
chmod 751 /var/log /etc/sysconfig
chmod 400 /etc/shutdown.allow /etc/sysctl.conf /etc/cron.*
chattr +i /etc/services /etc/group /etc/gshadow /etc/hosts.* /etc/xinetd.conf /etc/exports /bin/login
chattr +a /var/log/messages
/etc/sysconfig/syslog:SYSLOGD_OPTIONS="-r -m 0" 接收遠端日誌。/etc/syslog.conf:*.* @log_server_IP 轉發日誌副本。loco 彩色過濾器(loco /var/log/messages | more)高亮 root 操作與異常指令。logwatch 定期自動分析並郵件通報 root/sudo/telnet/ftp 登入情況。定期掃描並備份基準線:
find / -xdev -type f -perm +6000 > /root/backup/audit/suid.log
find / -xdev -nouser -o -nogroup > /root/backup/audit/nouser.log
find / -xdev -type f -perm -2 > /root/backup/audit/other.log
部署 Tripwire(tripwire --init 建立資料庫,tripwire --check -M 定期比對異動並郵件通報),需依實際環境剪裁 twpol.txt 策略檔。
安裝 Snare(snare-core 守護程式 + 圖形介面),預設監控 root 操作、權限變更、敏感資料存取,可自訂規則。
安全無絕對,唯有纵深防禦與持續營運。
CentOS 編譯安裝 Apache HTTPD 2.4 完整教程:APR/APR-Util/PCRE 依賴鏈、configure 參數、目錄佈局
解決 mkimage command not found:U-Boot 編譯 mkimage 工具與安裝指南
Bash PS1 提示符定制完全指南:變量含義、顏色設置、持久化配置
BusyBox 建構嵌入式 Linux 檔案系統完整實戰指南
Linux exec 與檔案描述符進階技巧:重導向、持久化、管道與 find 實戰
Azure 高可用架構設計實戰:Load Balancer (區域內) 與 Traffic Manager (全域/混合) 四大部署模式圖解