LINUX安全加固规范

2015-11-24 hapt 黑白之道 黑白之道


1概述... 5

2 安装... 5

3 用户帐号安全Password and account security. 6

3.1 密码安全策略... 6

3.2 检查密码是否安全... 6

3.3 Password Shadowing. 6

3.4 管理密码... 6

3.5 其它... 7

4 网络服务安全(Network Service Security)7

4.1服务过滤Filtering. 8

4.2 /etc/inetd.conf9

4.3 R 服务... 9

4.4 Tcp_wrapper9

4.5 /etc/hosts.equiv 文件... 10

4.6 /etc/services10

4.7 /etc/aliases11

4.8 NFS. 11

4.9 Trivial ftp (tftp)11

4.10 Sendmail11

4.11 finger12

4.12 UUCP. 12

4.13 World Wide Web (WWW) – httpd. 13

4.14 FTP安全问题... 13

5 系统设置安全(System Setting Security)14

5.1限制控制台的使用... 14

5.2系统关闭Ping. 14

5.3关闭或更改系统信息... 15

5.4 /etc/securetty文件... 15

5.5 /etc/host.conf文件... 15

5.6禁止IP源路径路由... 15

5.7资源限制... 16

5.8 LILO安全... 16

5.9 Control-Alt-Delete 键盘关机命令... 17

5.10日志系统安全... 17

5.11修正脚本文件在“/etc/rc.d/init.d”目录下的权限... 17

6 文件系统安全(File System Security)18

6.1文件权限... 18

6.2控制mount上的文件系统... 18

6.3备份与恢复... 19

7 其它... 19

7.1使用防火墙... 19

7.2使用第三方安全工具... 19

7.3参考网站... 19


1概述

近几年来Internet变得更加不安全了。网络的通信量日益加大,越来越多的重要交易正在通过网络完成,与此同时数据被损坏、截取和修改的风险也在增加。

只要有值得偷窃的东西就会有想办法窃取它的人。Internet的今天比过去任何时候都更真实地体现出这一点,基于Linux的系统也不能摆脱这个普遍规律而独善其身。因此,优秀的系统应当拥有完善的安全措施,应当足够坚固、能够抵抗来自Internet的侵袭,这正是Linux之所以流行并且成为Internet骨干力量的主要原因。但是,如果你不适当地运用Linux的安全工具,它们反而会埋下隐患。配置拙劣的安全系统会产生许多问题,本文将为你解释必须掌握的Linux安全知识。 本文讲述了如何通过基本的安全措施,使Linux系统变得可靠。

2 安装

使系统处于单独(或隔离)的网络中。以防止未受保护的系统连接到其它网络或互联网中受到可能的攻击

安装完成后将下面软件卸载

pump apmd lsapnptools redhat-logos

mt-st kernel-pcmcia-cs Setserial redhat-relese

eject linuxconf kudzu gd

bc getty_ps raidtools pciutils

mailcap setconsole gnupg

用下面的命令卸载这些软件:

[root@deep]#rpm –e softwarename

卸载它们之前最好停掉三个进程:

[root@deep]# /etc/rc.d/init.d/apmd stop

[root@deep]# /etc/rc.d/init.d/sendmail stop

[root@deep]# /etc/rc.d/init.d/kudzu stop

3 用户帐号安全Password and account security

3.1 密码安全策略

l 口令至少为6位,并且包括特殊字符

l 口令不要太简单,不要以你或者有关人的相关信息构成的密码,比如生日、电话、姓名的拼音或者缩写、单位的拼音或者英文简称等等。

l 口令必须有有效期

l 发现有人长时间猜测口令,需要更换口令

3.2 检查密码是否安全

可以使用以下几种工具检查自己的密码是否安全:

l JOHN,crack等暴力猜测密码工具

l 在线穷举工具,包括Emailcrk、流光等

3.3 Password Shadowing

l 使用shadow来隐藏密文(现在已经是默认配置)

l 定期检查shadow文件,如口令长度是否为空。

#awk -F: length($2)==0 {print $1} /etc/shadow

l 设置文件属性和属主

3.4 管理密码

l 设置口令有效最长时限 (编辑/etc/login.defs文件)

l 口令最短字符 (如linux默认为5,可以通过编辑/etc/login.defs修改)

l 只允许特定用户使用su命令成为root

编辑/etc/pam.d/su文件,在文件头部加上:

auth sufficient /lib/security/pam_rootok.so debug

auth required /lib/security/pam_wheel.so group=wheel

Red hat 7.0su文件已做了修改,直接去掉头两行的注释符就可以了

[root@deep]# usermod -G10 admin来将用户加入wheel

3.5 其它

l 清除不必要的系统帐户

[root@deep]# userdel adm

[root@deep]# userdel lp

[root@deep]# userdel sync

[root@deep]# userdel shutdown

[root@deep]# userdel halt

[root@deep]# userdel news

[root@deep]# userdel uucp

[root@deep]# userdel operator

[root@deep]# userdel games (如果不使用 X Window,则删除)

[root@deep]# userdel gopher

[root@deep]# userdel ftp (如果不使用ftp服务则删除)

l 尽量不要在passwd文件中包含个人信息,防止被finger之类程序泄露。

l 修改shadow,passwd,gshadow文件不可改变位

[root@deep]# chattr +i /etc/passwd

[root@deep]# chattr +i /etc/shadow

[root@deep]# chattr +i /etc/group

[root@deep]# chattr +i /etc/gshadow

l 不要使用.netrc文件,可以预先生成$HOME/.netrc。设置为0000

touch /.rhosts chmod 0 /.rhosts

l 使用ssh来代替telnetd,ftpd.pop等通用服务。传统的网络服务程序,如:ftppoptelnet在本质上都是不安全的,因为它们在网络上用明文传送口令和数据。

. . . . . .

欲知详情还请下载查看:

http://pan.baidu.com/s/1kTJD8bH