Ubuntu可通過以下步驟利用SELinux增強安全性:
安裝SELinux:
sudo apt update
sudo apt install selinux-basics selinux-policy-default
啟用SELinux:
sudo setenforce 1
/etc/selinux/config
,將SELINUX=disabled
改為SELINUX=enforcing
,然后重啟系統。配置SELinux策略:
cat /etc/selinux/config
semanage
管理策略(如添加文件上下文):sudo semanage fcontext -a -t httpd_sys_content_t "/path/to/file"
sudo restorecon -v "/path/to/file"
audit2allow
工具生成策略模塊并加載。監控與調試:
sestatus
sudo ausearch -m avc -ts recent
(結合audit2why
解讀拒絕事件)。注意事項: