Linux命令:selinux
- 基础命令
- 8天前
- 23热度
- 0评论
1、基础命令
获取运行状态
getenforce
可能返回结果有三种:Enforcing、Permissive 和 Disabled。Disabled 代表 SELinux 被禁用,Permissive 代表仅记录安全警告但不阻止 可疑行为,Enforcing 代表记录警告且阻止可疑行为。
临时关闭
setenforce 0
临时开启
setenforce 1
永久改变状态
vi /etc/selinux/config
2、端口授权
查看selinux允许的ssh端口
semanage port -l | grep ssh
增加新的端口
semanage port -a -t ssh_port_t -p tcp 6000
关闭一个端口
semanage port -d -t ssh_port_t -p tcp 6000
3、服务授权
查看是否允许ftp服务访问
getsebool -a | grep ftp
allow_ftpd_anon_write --> off
授权允许
setsebool -P allow_ftpd_anon_write=1
或者
setsebool -P ftp_home_dir on
4、目录访问授权
查看目录权限
semanage fcontext -l | grep /var/www/
修改
chcon -R -t httpd_sys_content_t /opt/www
安装selinux管理命令工具
yum -y install policycoreutils-python setroubleshoot
查看安全日志
sealert -a /var/log/audit/audit.log | more