原文地址为:http://www.webhostingtalk.com/showthread.php?t=468168
译者:Botu Sun < botus@acm.org >
=========================================
检查 formmail
=========================================
Form mail 通常被黑客用来发送垃圾邮件,如果你使用了 Matt 的 Script 或者其他一些类似的东西,当心你咯。
检查命令如下
Command to find pesky form mails:
find / -name "[Ff]orm[mM]ai*"
CGIemail is also a security risk:
find / -name "[Cc]giemai*"
Command to disable form mails:
chmod a-rwx /path/to/filename
(赋予 a-rwx 权限,这样就没有读写和执行的权限啦).
(这个东西会禁用 form mail)
如果有其他管理员在你的 VPS 上安装 form mail,请记得要告诉他们喔。
=========================================
Root kit checker – http://www.chkrootkit.org/
=========================================
将 rootkit 的检查列为一个 cron job 去自动周期执行,还是很有必要的。因为 rootkit 一般直接打入你的系统任督六脉,直入内核的,所以一般也很难察觉到。Root kit checker 自然能检查到你的系统里是不是被人植入了 rootkit。一般黑客通过各种手段进入你的系统后,一定会找各种方法提升 root 权限,然后给你来一个 rootkit,到时候搞的一团糟就不好了嘛,而且,很可能你要就此重新安装一个系统了。对了,别忘了一定要去官网下载最新版本,不要用来路不明的包。
首先登录 SSH,记得要用 root 身份哈
# cd /root/
# wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz
# tar xvzf chkrootkit.tar.gz
# cd chkrootkit-0.44
# make sense
执行 chkrootkit
/root/chkrootkit-0.44/chkrootkit
最好写入 cron job 吧。另外下面三个是我最经常使用的命令
./chkrootkit
./chkrootkit -q
./chkrootkit -x | more
=========================================
安装 root 登录警示邮件
=========================================
一般情况下,没有人会没事就登录 root 玩玩吧?在安装配置完成后,执行这项工作还是很必要的。每次有人激活了 root 的 shell 权限,就会给你来一封 email,告诉你什么时候,从哪个 IP 登录的 root,很酷吧?
首先来看看怎么发送警示邮件的,特别注意:一定要用 root 登录!!!
pico .bash_profile
在最后一行加入
echo 'ALERT - Root Shell Access on:' `date` `who` | mail -s "Alert: Root Access from `who | awk '{print $6}'`" your@email.com
保存 – 退出即可
再来看看如何设置 SSH 提示信息的,一样要注意,要用 root 登录!!!
pico /etc/motd
里面就是你的涂鸦板了,随意你怎么恐吓侵入你 VPS 的家伙。下面这段东西是我用的
ALERT! You are entering a secured area! Your IP and login information
have been recorded. System administration has been notified.
This system is restricted to authorized access only. All activities on
this system are recorded and logged. Unauthorized access will be fully
investigated and reported to the appropriate law enforcement agencies.
=========================================
更多的安全小技巧…
=========================================
限制 IP 登录 SSH
如果你的 IP 稳定在某一个范围,或者根本就是固定 IP,就可以通过配置 SSHd 来完成对某个 IP 的登录的授权,而其他的,嘿嘿,别想进来!
pico /etc/ssh/sshd_config
找到类似下面的配置行
#Port 22
#Protocol 2, 1
#ListenAddress 0.0.0.0
#ListenAddress ::
Uncomment and change
#Port 22
Port 5612
这里可以把端口改了,别 22 了,随便搞个什么 5612 之类的都行
Uncomment and change
#Protocol 2, 1
去掉前面的注释符号
Protocol 2
Uncomment and change
#ListenAddress 0.0.0.0
to look like
ListenAddress 123.123.123.15 (可以改成你的独立 IP 地址)
这里看你要不要让 root 直接登录了
#PermitRootLogin yes
and uncomment it and make it look like
PermitRootLogin no
重新启动 SSH 以便使配置文件生效
/etc/rc.d/init.d/sshd restart
禁用 Telnet
pico -w /etc/xinetd.d/telnet
将 disable = no 修改为 disable = yes
保存并重启 telnet
/etc/init.d/xinetd restart
禁用一些不需要 su 成 root
命令如下
locate shell.php
还有
locate irc
locate eggdrop
locate bnc
locate BNC
locate ptlink
locate BitchX
locate guardservices
locate psyBNC
locate .rhosts
关闭 Apache 的签名信息
(这样做,可以隐藏你的 Apache 版本信息)
root 登录后执行
pico /etc/httpd/conf/httpd.conf
找到如类似下面的配置信息,并修改为 off
ServerSignature Off
重启 apache
/etc/rc.d/init.d/httpd restart
=========================================
安装 BFD (喂喂,不是 Boy Friend Defender 啦,是 Brute Force Detection – 可选)
=========================================
要安装 BFD,root 登录之并执行
cd /root/
wget http://www.rfxnetworks.com/downloads/bfd-current.tar.gz
tar -xvzf bfd-current.tar.gz
cd bfd-0.4
./install.sh
修改配置文件
pico /usr/local/bfd/conf.bfd
找到
ALERT_USR=”0″
修改为
ALERT_USR=”1″
找到
EMAIL_USR=”root”
修改为
EMAIL_USR=”your@email.com”
保存并退出
启动 BFD
/usr/local/sbin/bfd -s
配置 LogWatch
LogWatch 很强大喔,RHEL 5 里默认就安装这个东西了(没记错的话),他可以将你的系统日志经过整理后,发送给你一份报告,详细程度都可以修改的。
root 登录,执行
pico -w /etc/log.d/conf/logwatch.conf
找到
MailTo = root
修改为
Mailto = your@email.com
Note: Set the e-mail address to an offsite account incase you get hacked.
找到
Detail = Low
修改为 5 或者 10 什么的随便你,5 是中等详细,10是非常详细
Detail = 5 or Detail = 10
我来了。