selinux-网络服务安全
一、显示和设置selinux
[root@localhost ~]# vim /etc/sysconfig/selinux //强制模式 许可模式 禁用模式
[root@localhost ~]# getenforce //查看当前SElinux的状态
[root@localhost ~]# setenforce //可以在强制模式(1) 许可模式(0)之间切换
[root@localhost ~]# sestatus //列出目录SELinux使用的策略(Policy)
二、查看安全上下文
进程
ps -ZC sshd
文件
ll -dZ /var/www/html/
端口
[root@localhost ~]# yum provides *bin/semanage
[root@localhost ~]# semanage port -l |egrep '\<80\>'
http_port_t tcp 80, 443, 488, 8008, 8009,
8443
三、修改selinux 上下文
cp 、 mv 对上下文影像
cp:会重新生成安全上下文
mv:安全上下文则不变
Chcon:
1、 chcon –R httpd_sys_content_t
/webdata
2、 chcon –R –reference /var/www/html
/webdata //将前一个文件的上下文作为参考,赋给/webdata
例:ftp匿名上传
- 文件系统的权限
[root@localhost ~]# mkdir /var/ftp/music
[root@localhost ~]# setfacl -m u:ftp:rwx /var/ftp/music/
2. FTP服务器配置
anonymous_enable=YES
anon_upload_enable=YES
anon_mkdir_write_enable=YES
修改上下文
chcon –R public_content_rw_t
/var/ftp/music/
3.查看
[root@localhost ~]# getsebool -a | grep
ftpd
4.设置
[root@localhost ~]# setsebool -P allow_ftpd_anon_write on
5.启动
[root@localhost ~]# systemctl
start vsftpd
四、监控selinux策略冲突情况
部署selinux日志分析工具
1、安装setroubleshoot-server软件包,才能将SELinux消息发送至/var/log/messages
setroubleshoot-server侦听/var/log/audit/audit.log中的审核信息并将简短摘要发送至/var/log/messages
该摘要包括SELinux冲突的唯一标识符(UUIDs),可用于收集更多信息
2、systemctl restart rsyslog
Systemctl restart auditd
3、测试
[root@localhost ~]# vim /tmp/index.html
[root@localhost ~]# mv /tmp/index.html
/var/www/html/
[root@localhost ~]# curl http://localhost
<!DOCTYPE HTML PUBLIC "-//IETF//DTD
HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to
access /index.html //权限拒绝,不能访问
on this server.</p>
</body></html>
4、查看/var/log/messages
Nov 16 02:03:35 localhost setroubleshoot:
SELinux is preventing httpd from open access on the file
/var/www/html/index.html. For complete SELinux messages run: sealert
-l f1243e54-7eb7-458b-a260-ca1f8ff61070
……………………………………………………..
If you want to fix the label.
/var/www/html/index.html default label
should be httpd_sys_content_t.
Then you can run restorecon.
Do
# /sbin/restorecon -v
/var/www/html/index.html
………………..
[root@localhost ~]# /sbin/restorecon -v
/var/www/html/index.html
/sbin/restorecon reset
/var/www/html/index.html context
unconfined_u:object_r:user_tmp_t:s0->unconfined_u:object_r:httpd_sys_content_t:s0
5、访问成功
[root@localhost ~]# curl http://localhost
------------------------------
this is a test web !
selinux-网络服务安全的更多相关文章
- [转载]SELinux 环境下网络服务设置,配置 Apache 、Samba、NFS
原文地址:http://www.ibm.com/developerworks/cn/linux/l-cn-selinux-services1/index.html?ca=drs- 引言 SELinux ...
- Salesforce Apex页面中调用远端网络服务
本文介绍了Salesforce Apex页面中调用远端网络服务的实现过程. ### 注册远端网络服务 在使用Apex代码调用远端网络服务之前,首先需要在Salesforce中注册远端网络服务地址, 本 ...
- 1、linux网络服务实验 用PuTTY连接Linux
这个是大三下学期的Linux网络服务配置详解时,感觉老师上得简单,就整理下,岭南师范学院师弟妹有福,如果是蔡老师交的话,可以拿来预习,复习. 一.用PuTTY连接Linux ①.装有redhat系统的 ...
- /etc/xinetd.conf 和 /etc/xinetd.d/*【新网络服务配置】
http://blog.csdn.net/kelven2004/article/details/1701930 xinetd 是 inetd 的安全加强版,它内置了自己的 TCP wrapper, 可 ...
- 在docker里部署网络服务
之前试着玩玩docker有一阵子了,今天算是头一回正式在docker里部署网络服务. 本来想和lxc差不多的东西那自然是手到擒来,没想到还是改了很多. 第一个遇到的问题是,远程连到docker宿主机干 ...
- Nodejs·网络服务
本章是从NodeJS拥有的模块角度,讲述了网络服务中的应用: net ----- > TCP dgram --> UDP http -----> HTTP https ----> ...
- linux配置oracle11G监听及本地网络服务 及 数据库建库
配置监听及本地网络服务 在oracle用户的图形界面oracle用户中,新开启一个终端,输入命令netca 会弹出如下界面. 数据库建库 在oracle用户的图形界面oracle用户中,新开启一个终端 ...
- Oracle配置本地网络服务名
Oracle安装完成后,可以使用客户端自带的的网络配置向导(Net Configuration Assistant)进行配置 1.启动Net Configuration Assistant.选择&qu ...
- ubuntu 12.04 "系统的网络服务与此版本的网络管理器不兼容
ubuntu 12.04 "系统的网络服务与此版本的网络管理器不兼容“ 2013-05-10 21:18 2271人阅读 评论(0) 收藏 举报 今天上午在实验室一顿乱整,不知道整坏了什么, ...
- jmeter 建立一个网络服务的测试计划
如何创建一个 测试计划 测试一个网络服务. 你会 创建5个用户发送请求到一页. 同时,你会告诉用户运行测试两次. 的总数 请求用户请求(5)x(1)x(重复2次)= 10 HTTP请求. 来 建立测试 ...
随机推荐
- librtmp将本地FLV文件发布到RTMP流媒体服务器
没有用到ffmpeg库 可以将本地FLV文件发布到RTMP流媒体服务器 使用librtmp发布RTMP流可以使用两种API:RTMP_SendPacket()和RTMP_Write(). 使用RTMP ...
- div上下滚动
<div class="table-scrollable" style='height:601px'></div> <style> .table ...
- 打印-print.js
//打印开始// strPrintName 打印任务名// printDatagrid 要打印的datagridfunction CreateFormPage(ctx,strPrintName, pr ...
- easyui添加删除tooltip
/** * 扩展两个方法 */$.extend($.fn.datagrid.methods, { /** * 开打提示功能 * @param {} jq * @param {} params 提示消息 ...
- 数据库 Oracle数据库对象二
视图 --视图是对表逻辑抽象 --视图的好处:简化查询 --视图是一种虚表 --视图建立在已有表的基础上,视图赖以建立的这些吧称为基表. --向视图提供数据内容的语句为select语句,可以将视图理解 ...
- 使用JavaScript 和 CSS 实现图像缩放和剪裁(转)
英文原文:Scale and Crop an Image using Javascript and CSS 在页面上需要裁减和缩放一张图片是一个常见问题.缩放图片比较简单的方法是使用image的hig ...
- 使用 Entity Framework 7 进行 SQLite 的 CURD 操作
原文地址:http://www.oschina.net/translate/sqlite-crud-operation-using-entity-framework 介绍 我善于使用传统的SQL查询风 ...
- <mvc:annotation-driven />注解详解
<mvc:annotation-driven /> 是一种简写形式,完全可以手动配置替代这种简写形式,简写形式可以让初学都快速应用默认配置方案.<mvc:annotation-dri ...
- 查看linux系统外网ip命令
终端中输入 curl ipinfo.io 或者 curl ifconfig.me 即可通过IP地址检测网站提供的api获得取本机的外网IP,或者以 JSON 格式返回全部结果.
- c#后台修改前台DOM的css属性示例代码
<div id = 'div1' runat="server">haha</div> ----------- 后台代码中这样调用 div1.Style[&q ...