四,防止攻击系统安全设置
1,限制用户使用系统资源,主要包括资源最大进程数,内存使用量等.这样可以防止DOS类型攻击.
需要编辑文件
[root@tp /]# vi /etc/security/limits.conf
...
(这三行是添加的) www.2cto.com
* hard core 0 禁止创建core文件
* hard rss 5000 其他用户(除root)最多使用5M内存
* hard nproc 20 最多进程数限制在20
注:*表示所有登陆到linux的用户.
# End of file
[root@tp /]# vi /etc/pam.d/login
...
在文件末尾加入下面一行
session required /lib/security/pam_limits.so
2,限制控制台的访问
[root@tp /]# vi /etc/securetty
...
我们注释掉
tty1
# tty2
# tty3
# tty4
# tty5
# tty6
只留下tty1,这时,root仅可在tty1终端登录
3,禁止外来ping请求.
[root@tp /]# vi /etc/rc.d/rc.local
...
在最后加入一行
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
4,防止IP地址欺骗
[root@tp /]# vi /etc/host.conf
加入如下几行
order bind,hosts
multi off
nospoof on
5,禁止su命令进入root(这一部我反复测试总是不成功,group组里的用户依然不能su成root用户.希望知道的朋
友告诉我,谢谢)
[root@tp pam.d]# vi /etc/pam.d/su
...
在下面加入如下两行
auth sufficient /lib/security/pam_rootok.so debug
auth required /lib/security/pam_wheel.so group=xxx
这表示只有xxx组的用户可以su成root.
6,使用TCP_WRAPPER
在默认情况下linux系统允许所有请求,可用TCP_WRAPPER增强安全性,
在/etc/hosts.deny写入"ALL:ALL"禁止所有请求
[root@tp etc]# vi /etc/hosts.deny
#
# hosts.deny This file describes the names of the hosts which are
# *not* allowed to use the local INET services, as decided
# by the '/usr/sbin/tcpd' server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow. In particular
# you should know that NFS uses portmap!
"ALL:ALL"
把允许访问的客户,或服务添加到/etc/hosts.allow,冒号左边为服务,冒号右边为授权的机器
[root@tp etc]# vi /etc/hosts.allow
#
# hosts.allow This file describes the names of the hosts which are
# allowed to use the local INET services, as decided
# by the '/usr/sbin/tcpd' server.
#
vsftp:211.101.46.253 注:仅如许IP地址为211.101.46.253的机器访问FIP服务器
7.删减登录信息
[root@tp ~]# rm -f /etc/issue
[root@tp ~]# rm -f /etc/issue.net
[root@tp ~]# touch /etc/issue
[root@tp ~]# touch /etc/issue.net
五,确保开启服务的安全性
我们先来看一下自己系统开启了多少服务.
[root@tp ~]# ps -eaf | wc -l
55
我的是55
我们可以通过当前的进程里在来看一下都是什么服务
[root@tp ~]# ps -aux
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.3/FAQ
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.2 2592 560 ? S 21:02 0:00 init [3]