赞
踩
centos自带SELinux。
root@ubuntu:/home/wenyao/Desktop# getenforce
Permissive
#如果是disabled证明是未开启,而(enforcing,permissive,不同模式)证明已经开启
先编辑/etc/selinux/config
配置信息
SELINUX=enforcing
:表示所有违反安全策略的行为都将被禁止。SELINUX=permissive
:表示所有违反安全策略的行为不被禁止,但是会在日志中作记录。# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
#改为permissive(测试一般是permissive模式,会有警告提醒)
SELINUX=permissive
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
在根目录下创建隐藏文件.autorelabel
,然后重启Linux
#新建标志文件
touch /.autorelabel
#重启
reboot
#查看模式
root@ubuntu:/home/wenyao/Desktop# getenforce
#查看SELinux状态
root@ubuntu:/home/wenyao/Desktop# sestatus
模式切换不需要重启linux,而在关闭SELinux(设为disabled)或开启(设为permissive,Enforcing)需要重启Linux。
#将 SELinux 在 Enforcing 与 permissive 之间切换(不需要重启)
#0 : 转成permissive 宽容模式
#1 : 转成Enforcing 强制模式
#切换为宽容模式
setenforce 0
#想关闭只能去改配置文件/etc/selinux/config(需要重启)
vim /etc/selinux/config
安装SELinux
,Utunbu
似乎不是自带SELinux
的,而是使用AppArmor
代替。
本人在Utunbu20.4
测试,发现只有AppArmor
,所以我需要使用SELinux
进行替换。
#暂停apparmor
sudo systemctl stop apparmor
#卸载apparmor
sudo apt purge apparmor
#更新apt源
sudo apt update
#安装SELiunx需要的包
sudo apt install policycoreutils selinux-utils selinux-basics
#验证安装成功(会被告知你需要重启)
sudo selinux-activate
#重启
reboot
也是/etc/selinux/config
配置信息,会发现跟centos那边的SELinux的配置文件有一些些不同,不过主题内容大致一致。
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
#默认是premissive
SELINUX=permissive
# SELINUXTYPE= can take one of these two values:
# default - equivalent to the old strict and targeted policies
# mls - Multi-Level Security (for military and educational use)
# src - Custom policy built from source
SELINUXTYPE=default
# SETLOCALDEFS= Check local definition changes
SETLOCALDEFS=0
验证方式没改变
root@ubuntu:/home/wenyao/Desktop# getenforce
Permissive
root@ubuntu:/home/wenyao/Desktop# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: default
Current mode: permissive
Mode from config file: permissive
Policy MLS status: enabled
Policy deny_unknown status: allowed
Memory protection checking: requested (insecure)
Max kernel policy version: 33
跟Centos一样。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。