Ⅱ 10.selinux的初级管理


1.什么时selinux


selinux,内核级加强型防火墙

 

2.如何管理selinux级别


selinux开启或者关闭)


vim  /etc/sysconfig/selinux

 

selinux=enforcing ##强制状态

selinux=permissive ##警告状态

selinux=disabled ##关闭状态

Linux学习笔记24 --selinux的管理 

 

getenforce ##查看状态


selinux开启时

setenforce  0|1 ##更改selinux运行级别

  -0 表示 permissive #警告

  -1 表示 enforcing #强制

 Linux学习笔记24 --selinux的管理


3.如何更改文件安全上下文


临时更改)

chcon -t 安全上下文 文件

chcon  -t public_content_t  /westos-R

 

永久更改)

semanage  fcontext -l ##列出内核安全上下文列表内容

semanage  fcontext -a  -t public_content_t  '/westos(/.*)?'

restorecon  -FvvR  /westos/


示例:

[[email protected] ~]# mkdir /westos

[[email protected] ~]# ps auxZ | grep vsftpd

[[email protected] ~]# ls -lZ /var/ftp/

[[email protected] ~]# ls -Zd /westos/

[[email protected] ~]# semanage fcontext -l | grep westos

[[email protected] ~]# semanage fcontext -l | grep /var/ftp

[[email protected] ~]# semanage fcontext -a -t public_content_t '/westos(/.*)?'

[[email protected] ~]# semanage fcontext -l | grep westos

[[email protected] ~]# ls -Zd /westos/

[[email protected] ~]# restorecon -RvvF /westos/

[[email protected] ~]# ls -Zd /westos/

[[email protected] ~]# touch /westos/file

[[email protected] ~]# ls -Z /westos/

 Linux学习笔记24 --selinux的管理

 

4.如何控制selinux对服务功能的开关


getsebool  -a grep 服务名称 #显示布尔值

getsebool  -a  grep ftp

setsebool  -P 功能bool值  on|off #修改 SELinux 策略 , 以永久保留修改。

setsebool  -Pftpd_anon_dir on

 Linux学习笔记24 --selinux的管理

 

5.监控selinux的错误信息

安装 setroubleshoot-server 软件包

[[email protected] ~]# yum info setroubleshoot-server.x86_64  #查看已安装及可安装的软件包

[[email protected] ~]# yum install setroubleshoot-server.x86_64 -y#安装seltroubleshoo-server服务

 

etroubleshoot-server 侦听 /var/log/audit/audit.log 中的审核信息并将简短摘要发送至 /var/log/messages

 

摘要包括 SELinux 冲突的唯一标识符 ( UUIDs ),可用于收集更多信息。 Sealert -l UUID 用于生成特定事件的报告。 Sealert -a

/var/log/audit/audit.log 用于在该文件中生成所有事件的报告

相关文章: