Chinaunix首页 | 论坛 | 博客
  • 博客访问: 10494775
  • 博文数量: 2905
  • 博客积分: 20098
  • 博客等级: 上将
  • 技术积分: 36298
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-23 05:00
文章存档

2012年(1)

2011年(3)

2009年(2901)

分类: LINUX

2009-03-23 11:23:34

 .网络的安全设置

  在这一部分,再次强调一定要修改/etc/inetd.conf,安全的策略是禁止所有不需要的服务.除此之外,还有以下几个文件和网络安全相关.
  (1)./etc/ftpusers ftp服务是一个不太安全的服务,所以/etc/ftpusers限定了不允许通过ftp访问linux主机的用户列表.当一个ftp请求传送到ftpd,ftpd首先检查用户名,如果用户名在/etc/ftpusers,ftpd将不会允许该用户继续连接.范例文件如下
:
# /etc/ftpusers - users not allowed to login via ftp
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody
nadmin

  (2)/etc/securetty linux系统中,总共有六个终端控制台,我们可以在/etc/securetty中设置哪个终端允许root登录,所有其他没有写入文件中的终端都不允许root登录.范例文件如下
:

# /etc/securetty - tty's on which root is allowed to login
tty1
tty2
tty3
tty4
(3)tcpd
的控制登录文件/etc/hosts.allow
/etc/hosts.deny
  在tcpd服务进程中,通过在/etc/hosts.allow/etc/hosts.deny中的访问控制规则来控制外部对linux主机的访问.它们的格式都是

  service-list : hosts-list [ : command]
  服务进程的名称 : 主机列表 可选,当规则满足时的操作

  在主机表中可以使用域名或ip地址,ALL表示匹配所有项,EXCEPT表示除了某些项, PARANOID表示当ip地址和域名不匹配时(域名伪装)匹配该项.

  范例文件如下
:
#
# 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.
#
ALL : 202.112.13.0/255.255.255.0
ftpd: 202.117.13.196
in.telnetd: 202.117.48.33
ALL : 127.0.0.1

  在这个文件中,网段202.112.13.0/24可以访问linux系统中所有的网络服务,主机202.117.13.196只能访问ftpd服务,主机202.117.48.33只能访问telnetd服务.本机自身可以访问所有网络服务
.
  在/etc/hosts.deny文件中禁止所有其他情况
:
  
#/etc/hosts.deny
  
ALL : DENY : spawn (/usr/bin/finger -lp @%h | /bin/mail -s "Port Denial noted in %d-%h" root)

  在/etc/hosts.allow,定义了在所有其他情况下,linux所应该执行的操作.spawn选项允许linux系统在匹配规则中执行指定的shell命令,在我们的例子中,linux系统在发现无授权的访问时,将会发送给超级用户一封主题是"Port Denial noted in %d-%h"的邮件,在这里,我们先要介绍一下allowdeny文件中的变量扩展
.

  (4)/etc/issue
/etc/issue.net

  在我们登录linux系统中的时候,我们常常可以看到我们linux系统的版本号等敏感信息.在如今的网络攻击行为中,许多黑客首先要收集目标系统的信息,版本号等就是十分重要的信息,所以在linux系统中一般要把这些信息隐藏起来./etc/issue/etc/issue.net就是存放这些信息的文件.我们可以修改这些文件来隐藏版本信息
.

另外,在每次linux重新启动的时候,都会在脚本/etc/rc.d/rc.local中再次覆盖上面那两个文件./etc/rc.d/rc.local文件的范例如下
:
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

if [ -f /etc/redhat-release ]; then
R=$(cat /etc/redhat-release)

arch=$(uname -m)
a="a"
case "_$arch" in
_a*) a="an";;
_i*) a="an";;
esac

NUMPROC=`egrep -c "^cpu[0-9]+" /proc/stat`
if [ "$NUMPROC" -gt "1" ]; then
SMP="$NUMPROC-processor "
if [ "$NUMPROC" = "8" -o "$NUMPROC" = "11" ]; then
a="an"
else
a="a"
fi
fi

# This will overwrite /etc/issue at every boot. So, make any changes you
# want to make to /etc/issue here or you will lose them when you reboot.
#echo "" > /etc/issue
#echo "$R" >> /etc/issue
# echo "Kernel $(uname -r) on $a $SMP$(uname -m)" >> /etc/issue

cp -f /etc/issue /etc/issue.net
echo >> /etc/issue

  在文件中黑体的部分就是得到系统版本信息的地方.一定要将他们注释掉
.

  (5)其他配置

  在普通微机中,都可以通过ctl+alt+del三键的组合来重新启动linux.这样是十分不安全的,所以要在/etc/inittab文件中注释该功能:
  
# Trap CTRL-ALT-DELETE
  #ca::ctrlaltdel:/sbin/shutdown -t3 -r now
阅读(810) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~