2007-02-06

打造Linux下超级安全的LAMP服务器

来源: 本站收集整理 作者:佚名 评论 0 条
 
[root@debian /]cd ~
[root@debian ~]ll
total 13K
-rw------- 1 root root 1.8K Sep 28 21:05 .bash_history
-rw------- 1 root root 14 Sep 29 09:29 .mysql_history
我们可以看到这两个文件里面都记录了东西的,下面我们处理他们
[root@debian ~]rm .bash_history
[root@debian ~]rm .mysql_history
[root@debian ~]ln -s /dev/null .bash_history
[root@debian ~]ln -s /dev/null .mysql_history
我们再看看
[root@debian ~][root@debian ~]ll
total 10K
lrwxrwxrwx 1 root root 9 Sep 29 09:29 .bash_history -> /dev/null
lrwxrwxrwx 1 root root 9 Sep 29 09:29 .mysql_history -> /dev/null
现在可以放心的设置密码了
[root@debian ~]mysqladmin -u root password mypasswd
这样我们以后root就得通过"mypasswd"这个密码来访问mysql数据库了

然后我们删除多余的数据库并去掉匿名帐号
[root@debian ~]mysql -u root -p
Enter password:XXXXXX

mysql> drop database test;
mysql> use mysql;
mysql> delete from db;
mysql> delete from user where not (host="localhost" and user="root");
mysql> flush privileges;

然后修改默认的治理员帐号root为你喜欢的,我这里改成fatb

mysql> update user set user="fatb" where user="root";
mysql> flush privileges;
以后我们就得通过fatb帐号访问mysql数据库了
[root@debian ~]mysql -u root -p
Enter password:
ERROR 1045: Access denied for user: 'root@localhost' (Using password: YES)
[root@debian ~]mysql -u fatb -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 14 to server version: 4.0.13-log
到这里,mysql的安全设置基本上完毕了

现在我们安装mod-security,debian下同样很简单,并且自动把模块加到httpd.conf里
[root@debian /]apt-get install libapache-mod-security
默认这个模块是没激活的,编辑一下httpd.conf文件并去掉下面这行的注释
LoadModule security_module /usr/lib/apache/1.3/mod_security.so
接着在httpd.conf的末尾加上

# 打开或者关闭过滤引擎
SecFilterEngine On
# 设置缺省的动作
SecFilterDefaultAction "deny,log,status:404"
# 把设置传递给字目录
SecFilterInheritance Off
# 检测URL编码是否正确
SecFilterCheckURLEncoding On
# 检测内容长度以避免堆溢出攻击
SecFilterForceByteRange 32 126
# 日志文件的位置和名字
SecAuditLog logs/audit_log
# debug设置
SecFilterDebugLog logs/modsec_debug_log
SecFilterDebugLevel 0
# 检测POST数据
SecFilterScanPOST On
# 当匹配sh的时候,重新定向到一个非凡的页面,让攻击者知难而退
SecFilter sh redirect:http://secu.zzu.edu.cn/hack/fu.htm
# Only check the body of the POST request
#过滤一些敏感的东西,我们使用*是为了攻击者使用/etc/./passwd来绕开检测
SecFilter /etc/*passwd
SecFilter /bin/*sh
# 防止double dot攻击,也就是类似
共6页: 上一页 [1] [2] [3] 4 [5] [6] 下一页

(本文仅表明作者个人观点,不代表本站及其管理员立场.) 推荐 收藏 投稿 打印 返回 关闭
上一篇:自己动手做一个迷你型Linux操作系统  
下一篇:Linux操作系统内核启动参数详细解析
    评论加载中…
 推荐文章
     

网站首页  -  网站地图 -   站长论坛  -  网站投稿  -    -  网站管理
Copyright © 2008 芜湖站长站 All Rights Reserved 皖ICP备07500611号