前言:

    文章是出于对自己在构建和管理过程中的一些总结。也希望对那些喜欢自己构建服务器的朋友有些作用。服务器安全是个很大的话题,也没有办法在短短文章里面全部涉及,我也没有那样的能力,我只是想给大家一个安全的概念,要想得到更详细的资料可以搜索其他文章来学习,也可以参考我给出的参考网址,可能在我文章里面的内容有不妥的地方,也请指出来。我的联系方式:liwenfei@163.net.

目录:
1.基本情况
2.安装系统
3.删除不必要的服务
4.编译内核或升级内核.
5.建立防火墙脚本
  iptables
6.远程登陆&&另一个防火墙
  ssh
  tcp_wrapper
  hosts.allow  hosts.deny
7.监测&&扫描
   MRTG snort  portsentry logsentry  nessus
8.校验文件
   md5sum
   PGP&&GPG
   tripwire

正文:

1.基本情况:
安装linux首先重要的是了解自己的硬件信息,好看看我的服务器配置,各位看家也可以去试试了解自己的硬件情况:
17寸ibm显示器:类型ibm 6547 水平刷新率30-69 垂直刷新率50-1202.
显卡:类型NVIDIA GEFORCE 2 MX (generic)
内存:类型dimm hy256
cpu: 类型intel pIII 1.0G
硬盘:类型酷鱼6.4G
主板:磐英ep-3pta
声卡:板载的intel 82801IBA/BAM ac'97 audio
网卡:REALTEK RTL-8029
有了这些配置的详细情况,就可以为后面的工作做的足够的准备工作了。

网络情况:
a.单网卡
b.带两台上网,需要共享,利用了ip伪装来实现
c.利用rp-pppoe来拨号

2.安装系统
根据我用过linux还是比较喜欢redhat,尤其是redhat8.0我一般都是安装这个系统,原因-稳定。安装系统也是比较简单了.如果你没有安装过,就先看看其他的一些文章,这个没有办法教你怎样安装。这里谈论安装注意的问题:
重要是分区。如何划分,这个是看个人的需要的,我的是这样分的
/dev/hdb1  /boot   100M
/dev/hdb2  /  6.4G-100M-256*2M
/dev/hdb3  swap    256*2M
呵呵,太小只能这样分了,/boot这个分开作为一个区。你也可以把/里面的主要放软件的/usr 放用户资料的/home和放日志的/var几个分成几个区。这几个是膨胀的最快的。
以后的就都基本默认安装了。
其次是安装需要的软件,你需要什么就安装什么,要不你什么也不要安装,以后下载tar安装.我就喜欢这样,自己下载tar包回来安装。
资料参考:

3.删除不必要的服务。
这个也是看人的需要的。不过默认安装的那些网络应用软件过久的就应该删除它。删除的方法rpm -e *
再下载新的tar.gz,我推荐用这个,因为可以更能发挥pc的作用。看看有那些服务,有什么删除不必要的服务或者是关掉它,setup看看你启动的服务。了解服务的作用:
amd 运行automount精灵程序,该精灵在必要时自动安装一些本地设备和NFS文件系统。
apmd apmd用来监视系统用电状态,并将相关信息通过syslogd 写入日志.也可以用来在电源不足时关机
arpwatch 该程序主要用来维护以太网物理地址和IP地址的对应关系。
atd 运行用户用At命令调度的任务。也在系统负荷比较低时 运行批处理任务。
autofs 当您需要时自动转载文件系统,而当您不需要时自动卸载。
bootparamd 该服务允许老的Sun工作站从Linux网络启动,它和rarp现在很少使用,基本上被bootp和dhcp取代了.
crond cron是Unix下的一个传统程序,该程序周期地运行用户 调度的任务。比起传统的Unix版本,Vixie版本添加了不少属性,而且更安全,配置更简单。 
dhcpd 该精灵提供了对动态主机控制协议(Dynamic Host Control Protocol)的访问支持。
ftpd FTP是文件传输协议的简称,它定义了在网络上从一台计算机向另一台计算机进行文件传输的方式,几乎所有的常用系统平台都提供 FTP的服务程序和客户程序
gated gated通过一个数据库提供了网络路由功能支持。它支持 各种路由 协议,包括RIP版本1和2、DCN HELLO协议、OSPF版本2以及EGP 版本2到4。
gpm gpm为文本模式下的Linux程序如mc(Midnight Commander)提供鼠标的支持。它也支持控制台鼠标的拷贝,粘贴操作以及弹出式菜单。
httpd http是著名的www服务器,可用来提供HTML文件以 及CGI动态内 容服务。
Inet 因特网操作服务程序。监控网络对各种它管理的服务的需求,并在 要的时候启动相应的服务程序。通常,inet管理的程序有telnet、
ftp、rsh和rlogin。关闭inet也就 关闭了这些由它管理的服务。
innd inn是最流行的用户组新闻服务器。它允许您建立起本地 新闻服务器。配置有一定的难度,可以先阅读/usr/doc/ inn*文档获得帮助。
keytable该程序的功能是转载您在/etc/sysconfig/keyboards里说明的键盘映射表,该表可以通过kbdconfig工具进行选 择。您应该使该程序处于激活状态。
ldap LDAP代表Lightweight Directory Access Protocol.实现了目录 访问协议的行业标准。
lpd lpd是系统打印守护程序,负责将lpr等程序提交给打印作业。
mcserv Midnight Commander服务进程允许远程机器上的用户通过Midnight
Commander文件管理器操作本机文件。服务进程用PAM来验证用户,需要给出“用户名/口令”以通过验证
mysql 一个快速高效可靠的轻型SQL数据库引擎。
named 域名服务器,将Internet主机名解析为点分的IP地址。
netfs 负责装载/卸载NFS、Samba、NCP(Netware)文件系统。
network 激活/关闭启动时的各个网络接口。
NFS是一个流行的基于TCP/IP网络的文件共享协议。该服务提供了NFS文件共享服务,具体的配置在/etc/ exports文件里。 
nscd 该服务负责密码和组的查询,并且缓冲查询结果。如果您的系统有比较慢的服务(如NIS和NIS+),则应该启动该服务。
Pcmcia pcmcia主要用于支持笔记本电脑。
Portmap portmap 用来支持RPC连接,RPC被用于NFS以及NIS 等服务。
postgresql PostgreSQL关系数据库引擎。
qmail 它也是一个基于UNIX操作系统的Internet邮件传输机构(Internet
Mail Transfer Agent 简称MTA)。它采用标准的简单邮件传输协议 (Simple Mail Transfer Protocol 简称SMTP)与Internet上其他
MTA交换信息,具有安全、可靠、高效、简单的特点。
random 保存和恢复系统的高质量随机数生成器,这些随机数是系统一些随机行为提供的。
routed 该守护程序支持RIP协议的自动IP路由表维护。RIP主要使用在小型网络上,大一点的网络就需要复杂一点的协议。
rstatd Rstat 协议允许网络上的用户获得同一网络上各机器的性能参数。
rusersd 该服务使网络用户可以定位同一网络上的其他用户。
rwalld Rwall协议允许远程用户向在同一系统中活跃着的终端发送消息,类似wall的本地行为。
rwhod 允许远程用户获得运行rwho精灵的机器上所有已登录用户的列表,与finger类似。
sendmail 大名鼎鼎的邮件服务器。
smb 启动和关闭smbd和nmbd精灵程序以提供SMB网络服务。
snmpd 简单网络管理协议(SNMP)的守护精灵。
syslog syslog是操作系统提供的一种机制,守护程序通常使用这种机制将各种信息写到各个系统日志文件。通常应该启动该服务。
Webmin webmin是基于web的集系统管理与网络管理于一身的强大管理工具.利用webmin的强大功能,用户可以通过web浏览器来方便地设置自己的服务器、dns、samba、nfs、本地/远程文件系统以及许多其他的服务.
还有很多其他的,要更详细的,要你自己去找资料看看了
也是按需开放服务。我一般开的服务anacron apmd atd autofs crond  gmp  iptables keytable kudzu  network random rawdevices servers  services  syslog xfs xinetd.

4.编译内核及升级
不明白编译的还是找相关文章看看。步骤也简单:
确定内核在/usr/src/linux目录
make mrproper
make dep
make clean
make bzImage && make modules && make modules_install
我喜欢后面的一起执行
我编译的是2.4.22的内核。其中加需要的上面介绍硬件的驱动,删除多余的硬件驱动和多加的放火墙的驱动。这个要认真看看内核里面到底有什么。
编译完,使用新的内核。还是写个简单shell脚本来执行。保存为kernel.sh

#!/bin/sh
echo "changeing kernel......"
echo "change vmlinuz!"
rm /boot/vmlinuz-2.4.22.old
mv /boot/vmlinuz-2.4.22.new  /boot/vmlinuz-2.4.22.old
cp /boot/vmlinuz-2.4.22  /boot/vmlinuz-2.4.22.new
cp /usr/src/linux/arch/i386/boot/bzImage /boot/vmlinuz-2.4.22
echo "change vmlinuz finished!!"
sleep 2
echo "change System.map!"
rm /boot/System.map-2.4.22.old
mv /boot/System.map-2.4.22.new  /boot/System.map-2.4.22.old
cp /boot/System.map-2.4.22 /boot/System.map-2.4.22.new
cp /usr/src/linux/System.map /boot/System.map-2.4.22
echo "change System.map finished!!"
echo "install kernel!"
new-kernel-pkg --mkinitrd --depmod --install 2.4.22
echo "finished all !!!"

5.建立防火墙
一个安全的服务器,防火墙是必不可少的。我使用了iptables做为自己的防火墙,这个继承在linux系统里面,功能十分强大也容易使用。看看基本的命令格式吧:
[*********]#iptables --help

iptables v1.2.6a
Usage: iptables -[ADC] chain rule-specification [options]
       iptables -[RI] chain rulenum rule-specification [options]
       iptables -D chain rulenum [options]
       iptables -[LFZ] [chain] [options]
       iptables -[NX] chain
       iptables -E old-chain-name new-chain-name
       iptables -P chain target [options]
       iptables -h (print this help information)
Commands:
Either long or short options are allowed.
  --append  -A chain            Append to chain
  --delete  -D chain            Delete matching rule from chain
  --delete  -D chain rulenum
                                Delete rule rulenum (1 = first) from chain
  --insert  -I chain [rulenum]
                                Insert in chain as rulenum (default 1=first)
  --replace -R chain rulenum
                                Replace rule rulenum (1 = first) in chain
  --list    -L [chain]          List the rules in a chain or all chains
  --flush   -F [chain]          Delete all rules in  chain or all chains
  --zero    -Z [chain]          Zero counters in chain or all chains
  --check   -C chain            Test this packet on chain
  --new     -N chain            Create a new user-defined chain
  --delete-chain
            -X [chain]          Delete a user-defined chain
  --policy  -P chain target
                                Change policy on chain to target
  --rename-chain
            -E old-chain new-chain
                                Change chain name, (moving any references)
Options:
  --proto       -p [!] proto    protocol: by number or name, eg. `tcp'
  --source      -s [!] address[/mask]
                                source specification
  --destination -d [!] address[/mask]
                                destination specification
  --in-interface -i [!] input name[+]
                                network interface name ([+] for wildcard)
  --jump        -j target
                                target for rule (may load target extension)
  --match       -m match
                                extended match (may load extension)
  --numeric     -n              numeric output of addresses and ports
  --out-interface -o [!] output name[+]
                                network interface name ([+] for wildcard)
  --table       -t table        table to manipulate (default: `filter')
  --verbose     -v              verbose mode
  --line-numbers                print line numbers when listing
  --exact       -x              expand numbers (display exact values)
[!] --fragment  -f              match second or further fragments only
  --modprobe=<command>          try to insert modules using this command
  --set-counters PKTS BYTES     set the counter during insert/append
[!] --version   -V              print package version.
不用晕头,不过这个不能做详细的说明,拿我用的来说明一些,更详细的需要你们自己学了.#!/bin/sh
echo "Start iptables rules....."
#Enable forward .
echo 1 > /proc/sys/net/ipv4/ip_forward#Modprobe modules
/sbin/modprobe ip_tables
/sbin/modprobe ip_nat_ftp
/sbin/modprobe ip_conntrack
/sbin/modprobe ip_conntrack_ftp#Enable fake .
/sbin/iptables -t nat -A POSTROUTING -s 172.19.16.1/24  -o ppp0 -j MASQUERADE#Set up new chain
/sbin/iptables -N mine#permit to set up new session
/sbin/iptables -A mine -m state --state ESTABLISHED,RELATED -j  ACCEPT
/sbin/iptables -A mine -m state --state NEW -i ! ppp0  -j ACCEPT#Enable visit my apache
/sbin/iptables -A mine -p tcp --dport 80 -i ppp0 -j ACCEPT#Enable visit openssh
/sbin/iptables -A mine -p tcp --dport 22 -i ppp0 -j ACCEPT#Enable visit ftp
/sbin/iptables -A mine -p tcp --dport ftp -i ppp0 -j ACCEPT
/sbin/iptables -A mine -p tcp --dport ftp-data -i ppp0 -j ACCEPT#Disable ping host
/sbin/iptables -A mine -p icmp  -i ppp0 -j ACCEPT####
/sbin/iptables -A mine -i ppp0 -m limit -j LOG --log-prefix "bad packet from ppp0:"
/sbin/iptables -A mine -i ! ppp0 -m limit -j LOG --log-prefix "bad packet not from ppp0:"
#Forbid all
/sbin/iptables -A mine -j DROP
/sbin/iptables -A INPUT -j mine
/sbin/iptables -A FORWARD -j mine

看看我里面的英文解释了,我懒得打字了,别扁我。:(更详细看看我给的资料参考。
这个脚本我也是借用别人的,再修改一些。限制只能访问开放端口的主机,但是不能限制ping 因为后面介绍MRTG的时候,要解析域名。

6.远程登陆及另一个防火墙
如果要远程管理的话,装个ssh是必不可少的了。现在大多数的的telnet都换成了ssh,目的-安全.安装了它,还要顺便设置你的hosts.allows 和hosts.deny. 限制远程机器的访问。你不是有的防火墙了吗?还弄这个干什么。多把锁-安全点.

那看看另外一个防火墙tcp_wrapper.不知道这个是什么,那就man tcpd 看看吧!安装简单,
将TCP_Wrapper软件包解压缩到任一目录中,输入:
tar xvf tcp_wrappers_7.6.tar
用vi打开Makefile文件,修改#REAL_DAEMON_DIR=/etc行,将前面的注释符#去掉,然后输入:
make SYS-type
SYS-type是系统类型。其它系统类型参阅Makefile文件。等编译完成后,会有tcpd等可执行文件。首先用tcpdchk检查tcpd是否有问题,若有,则列出警告信息,需要重新编译,直到无任何警告为止.

下面来说说他的配置,主要就是设置/etc/hosts.allows和/etc/hosts.deny两个文件,默认安装就应该有了.hosts.allows和hosts.deny 设置格式,简单的例子.只允许192.168.0网段的访问主机
在/etc/hosts.deny中设置
ALL: ALL
在/etc/hosts.allow中设置
ALL: 192.168.0.

如果你想某台机允许访问某服务也可以这样
/etc/hosts.allow
sshd :192.168.0.2
设置好,就重新启动tcpd,
可以先用tcpdmatch来检查一下你的设置,rpm包安装的未必有这个工具,可以下载tar.gz包来安装
#./tcpdmatch sshd 192.168.0.2
client: address 192.168.0.2
server: process sshd
matched: /etc/hosts.allow line 1(匹配:/etc/hosts.allow文件第1行)
access: granted (访问:允许)
只能192.168.0.2这个ip访问的了sshd.同时你可以看看日志文件,也会有记录.
如何,这个防火墙,简单明了,不妨一试!

 

7.监测
监测是网络维护中比较重要的一项,如果受到攻击也可以得到被攻击的第一手资料。下面就介绍几个好用的工具和简单用法:
首先就是MRTG.这个功能强大的监控软件.具体的安装和配置看看
http://aspx.crcec.com/show.aspx?ID=113.
简单安装说明:
需要软件包:GCC、Perl、gd、libpng和zlib snmp
可以使用下面的命令来判断系统是否安装有这些软 件包:

[***# rpm -qa|grep gd 
gd-1.8.4-4 
gd-devel-1.8.4-4 [***]# rpm -qa|grep perl 
perl-5.6.0-17 
mod_perl-1.24_01-3 [***]# rpm -qa|grep libp 
libpng-1.0.12-2 
libpng-devel-1.0.12-2 [***]# rpm -qa|grep zlib 
zlib-1.1.3-24 
zlib-devel-1.1.3-24 [***]#rpm -qa|grep gcc 
gcc-2.96-98 
gcc-g77-2.96-98 
gcc-c++-2.96-98 [***]#rpm -qa|grep snmp 
ucd-snmp-4.2.1-7 
ucd-snmp-utils-4.2.1-7 
ucd-snmp-devel-4.2.1-7 安装mrtg
[***]# tar xvfz mrtg-2.9.17.tar.gz 
[***]# cd mrtg-2.9.17 
[***]#  ./configure --prefix=/usr/local/mrtg-2 
[***]# make 
[***]# make install 配置snmpd.conf
vi /etc/snmp/snmpd.conf 
将 
#view systemview included mib2 
的内容修改为: 
view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc 
然后将 
access notConfigGroup "" any noauth exact systemview none none 
修改为: 
access notConfigGroup "" any noauth exact mib2 none none 
然后再重新启动snmpd: 
/etc/rc.d/init.d/snmpd restart 配置mrtg.cfg
利用cfgmaker自己配置mrtg.cfg文件,监控设备.
在mrtg的安装目录下/usr/local/mrtg-2
[*****]#cd bin
[*****]#./cfgmaker --global "WorkDir: /var/www/html/mrtg" / 
--global "Options[_]: growright,bits"  /
--ifref=ip                           /    //---name
--output /etc/mrtg.cfg                 /
public@172.19.16.24              /[****]#./mrtg  /etc/mrtg.cfg 
在前三次运行时可 能会报告遗失日志文件的告警信息,不要理睬这些信息,只需要连续运行三次以后再运行 就不会产生告警信息了则可以通过访问http://localhost/mrtg来访问生成的统计信息.
自动运行:
vi /etc/crontab
添加每三分钟就运行一次
*/3 * * * * /usr/local/mrtg-2/bin/mrtg /etc/mrtg.cfg 
重启crond
[***]#/etc/rc.d/init.d/crond restart

 

其次是snort,它是一个强大的轻量级的网络入侵检测系统。它具有实时数据流量分析和日志IP网络数据包的能力,能够进行协议分析,对内容进行搜索/匹配。它能够检测各种不同的攻击方式,对攻击进行实时报警。
安装说明:
首先需要安装libpcap-0.8.1.tar.gz可以到http://www.tcpdump.org/再安装snort.
[***]# tar zxvf snort-1.8.6.tar.gz
[***]# cd snort-1.8.6
[***]# ./configure --prefix=/usr/local/snort
[***]# make
[***]# make install

snort有三种工作模式:嗅探器、数据包记录器、网络入侵检测系统.

嗅探器方式直接输出到屏幕
[***]#./snort -d -v –e 
数据包记录器方式,可以记录到文件首先要建立一个目录,进入/usr/local/snort/bin目录
[***]#mkdir log
[***]#./snort -dev -l ./log
网络入侵检测系统 
必要配置:
snort.conf配置文件放在 snort-1.8.6目录下
[***]#cp ./etc/snort.conf /root/.snortrc
建立规则目录,复制规则
[***]#mkdir /usr/local/snort/rules
[***]#cp ./rules/* /usr/local/snort/rules
复制规则的分类说明文件到用户主目录
[***]#cp ./etc/classification.config /root
[***]#cp ./etc/reference.config  /root
建立存放日志的目录
[***]#mkdir /var/log/snort
修改配置文件
[***]#vi /root/.snortrc
修改RULE_PATH值为/usr/local/snort/rules
检验一下是否正确
[***]#/usr/local/snort/bin/snort -T 
最后出现
+++++++++++++++++++++++++++++++++++++++++++++++++++Rule application order: ->activation->dynamic->alert->pass->log
        --== Initialization Complete ==--
-*> Snort! <*-
Version 2.0.6 (Build 100)
By Martin Roesch (roesch@sourcefire.com, www.snort.org)Snort sucessfully loaded all rules and checked all rule chains!
Snort exiting
就代表成功了.
最后应用了
[***]# ./snort -d -c /root/.snortrc
查看你的/var/log/snort 得到结果

第三,如果有这样的工具,可以智能的发现攻击,自动将攻击者的IP屏蔽,那就好了,有这样的工具。
那就是PortSentry.他具体能做的,通过 syslog 做记录 ,将扫描的主机加入 /etc/hosts.deny ,马上禁止所有通向扫描主机的网络流量 ,过滤掉所有来自扫描主机的网络流量。   
那样前面的tcp_wrapper 的hosts.allow 和hosts.deny不必要设置.
安装方式看看这个吧
http://www.linuxaid.com.cn/engineer/brimmer/html/portsentry.htm也可以看PortSentry的README.install文件以获取更多的信息
简单安装:
[***]#make linux
[***]# make install
默认安装目录是/usr/local/psionic/
需要监听的端口,需要禁止、监控的IP地址可以去修改配置文件
/usr/local/psionic/portsentry.conf

希望PortSentry忽略的主机
在/usr/psionic/portsentry/portsentry.ignore文件中设置

启动 portsentry:
  portsentry -atcp (Advanced TCP stealth scan detection)
  portsentry -sudp ("Stealth" UDP scan detection)
一种 tcp 启动方式和一种 udp 启动方式可以同时进行。
以下命令加入 "/etc/rc.d/rc.local" 中,当系统重起时自动启动:
[***]# /usr/psionic/portsentry/portsentry -atcp
[***]# /usr/psionic/portsentry/portsentry -sudp

 

第四,日子久了,那么多日志文件,我能发现那些有问题啊?logsentry就可以做到。它会把有问题的日志总结起来发给管理员。
简单安装:
[***]#make linux
想知道安装在哪个目录可以打开Makefile文件看看,也可以修改安装目录
启动logsenrty
[***]#/usr/local/etc/logcheck
如何配置文件那就要请看INSTALL了.

第五,自己来分析一下,自己的主机有没有什么漏洞?
安装nessus来检查一下,详细资料到他们网站看看
http://www.nessus.org/demo/first.html

简单安装:
[***]#lynx -source http://install.nessus.org | sh
就会自动安装了,期间要输入root的密码.

创建一个nessusd 帐号

[***]# nessus-adduser
Addition of a new nessusd user
------------------------------
Login : renaud
Authentication (pass/cert) [pass] : pass
Password : secret
User rules
----------
nessusd has a rules system which allows you to restrict the hosts
that renaud2 has the right to test. For instance, you may want
him to be able to scan his own host only.Please see the nessus-adduser(8) man page for the rules syntax
Enter the rules for this user, and hit ctrl-D once you are done : 
(the user can have an empty rules set)deny 10.163.156.1
allow 10.163.156.0/24
default deny
Login            : renaud
Password         : secret
DN   :
Rules            :
deny 10.163.156.1
allow 10.163.156.0/24
default deny
Is that ok (y/n) ? [y] y
user added.启动服务
[***]#nessusd -D连接nessusd
[***]#nessus 打开一个窗口,按提示的则可以.8.校验文件
首先是md5sum:
下载了文件,不知道那么有没有被人改过。那就要来个校验了。在linux下就是md5sum .这个工具校验很简单.先看看md5sum 帮助
[***]# md5sum --help
Usage: md5sum [OPTION] [FILE]...
  or:  md5sum [OPTION] --check [FILE]
Print or check MD5 (128-bit) checksums.
With no FILE, or when FILE is -, read standard input.  -b, --binary            read files in binary mode (default on DOS/Windows)
  -c, --check             check MD5 sums against given list
  -t, --text              read files in text mode (default)The following two options are useful only when verifying checksums:
      --status            don't output anything, status code shows success
  -w, --warn              warn about improperly formated checksum lines      --help     display this help and exit
      --version  output version information and exit

简单使用:
产生校验文件,例如要对kernel.sh 检验文件。
[***]#md5sum kernel.sh > kernel.sh.md5
就这么简单。
检验也很简单,把下载的文件和检验文件放一起。
[***]#md5sum -c kernel.sh.md5
够简单吧!

其次,PGP&&GPG.
请先下载-软件和签名人公钥(KEYS.asc),放在一起
可以用软件 PGP或者GPG,导入公钥,在对文件进行校验。
[***]#pgp -ka KEYS
[***]#pgp apache_1.3.24.tar.gz.asc
或者
[***]#gpg --import KEYS
[***]#gpg --verify apache_1.3.24.tar.gz.asc
更多的用法,那就看看help文件吧!

最后,tripwire
下载的软件是可以基本保证是安全的了,那么在主机上运行的那些软件也一定就会安全了吗?
如果有黑客已经进入了你的机器,那你的软件也没有什么安全和完整可言。tripwire就可以用
来定时查看系统里面文件的完整性。

简单安装:
我这里用的是tripwire-2.3-47.bin.tar.gz
解压后进入目录执行,之前请认真读读README.
[***]#./install.sh
按照提示安装就行。我下载的版本有的地方有错修改一下,如果你的有问题,
可以相应修改install.cfg文件.
TWMAILPROGRAM="/usr/lib/sendmail -oi -t"
路径错误,修改为:
TWMAILPROGRAM="/usr/sbin/sendmail -oi -t"

使用:
看看说明,man tripwire.
先来看看help说明:

[***]# tripwire --help
tripwire: File integrity assessment application.
Tripwire(R) 2.3.0.47 for Linux
Tripwire 2.3 Portions copyright 2000 Tripwire, Inc. Tripwire is a registered
trademark of Tripwire, Inc. This software comes with ABSOLUTELY NO WARRANTY;
for details use --version. This is free software which may be redistributed
or modified only under certain conditions; see COPYING for details.
All rights reserved.
Usage:Database Initialization:  tripwire [-m i|--init] [options]
Integrity Checking:  tripwire [-m c|--check] [object1 [object2...]]
Database Update:  tripwire [-m u|--update]
Policy Update:  tripwire [-m p|--update-policy] policyfile.txt
Test:  tripwire [-m t|--test] --email addressType 'tripwire [mode] --help' OR
'tripwire --help mode [mode...]' OR
'tripwire --help all' for extended help

使用:
初始化数据库,产生特征码数据库文件,一般保存在/var/lib/tripwire/
[***]#tripwire --init
Please enter your local passphrase: <--输入密码
Parsing policy file: /etc/tripwire/tw.pol
Generating the database...
*** Processing Unix File System ***
有很多错误信息出来,由于策略文件编写不当造成的,可以忽略。
为了减少这些错误信息的出现,应该根据自己的系统仔细编辑你的策略文件。
成功了会显示
### Continuing...
Wrote database file: /var/lib/tripwire/***.twd
The database was successfully generated.

检查文件完整性:
[***]#tripwire --check
从报告中,你可以看到系统被改变的文件。
检查完成之后,如果系统没有异常情况,使用Tripwire的升级模式对特征码数据库进行升级就可以了,
报告都被保存在/var/lib/tripwire/report/目录中。

还有其他的,你们自己去探索了!

 

这里也只是介绍如何你防御别人入侵自己的主机,只要做好这些方面,你的主机就相对来说安全了。
不过还需要你了解被入侵后,应该做些什么工作,也是同样重要的。下面提供一些资料给你们.

资料参考:

LinuxAid 技术支持中心
http://www.linuxaid.com.cn/articles/4/1/410879828.shtml

网络流量监控器mrtg全攻略
http://aspx.crcec.com/show.aspx?ID=113

[ 永远的UNIX Unix文件安全检查利器- Tripwire ]
http://www.fanqiang.com/a5/b6/20011006/0805011408.html

数据完整性检测工具:Tripwire
http://pkucert.pku.edu.cn/lecture/sec/tripwire.htm

Tripwire.org - Home of the Tripwire Open Source Project
http://www.tripwire.org/

tripwire-2.3.1-2
http://lfs.linuxsir.org/htdocs/blfscvs/postlfs/tripwire.html

MHDN.net 明辉开发者网络[UNIX后门安全策略]

http://www.mhdn.net/se/2002-07-05/5429.html常见的两种签名及校验

http://hedong.3322.org/archives/000064.html

MHDN.net 明辉开发者网络[portsentry的安装配置]
http://www.mhdn.net/se/2002-06-14/5304.html

MHDN.net 明辉开发者网络[Tcp_wrapper的安装和使用]
http://www.mhdn.net/se/2002-06-14/5300.html

Linux系统中PortSentry的安装和配置
http://www.linuxaid.com.cn/engineer/brimmer/html/portsentry.htm

Snort 中文手册
http://www.fengnet.com/showart.asp?art_id=589&cat_id=10

安全的log纪录服务器
http://www.fengnet.com/showart.asp?art_id=586&cat_id=10

TCP_Wrapper防火墙的安装与配置
http://www.wxygzs.com/yc002.html

TCPDUMP public repository
http://www.tcpdump.org/绿盟科技--www.nsfocus.com--安全技术
 
http://www.nsfocus.net/index.php?act=sec_self&do=view&doc_id=728

Snort Users Manual Snort Release 2.0.0
http://www.snort.org/docs/writing_rules/

LogSentry
http://www.gnu.org/directory/security/misc/LogSentry.html

Tripwire.org - Downloads
http://www.tripwire.org/downloads/index.php

iptables 的资料
http://cmpp.linuxforum.net/NetSnake/iptables_man1.txt现成的 iptables 防火墙脚本
http://www.freelamp.com/new/publish/1003249502/index_html