当前位置: 首页 > 图文教程 > 操作系统 > Unix/Linux > DenyHosts 阻止SSH暴力破解最好的方法

Unix/Linux
RHEL 5服务器系统下故障处理方法
Linux系统下图形界面更改IP地址
Linux操作系统下禁止单用户模式登录的操作方法
Linux中QQ软件的安装和配置
linux 操作系统 uniq命令的说明和使用
Linux 上如何使用QQ和MSN工具
The file /boot/grub/stage1 not read cor 解决办法
如何修改apache 2最大连接数
4G内存时linux的mtrr表不正确的解决
制作Linux的U盘(usb)启动盘
Linux Telnet登录慢问题解决
LINUX操作系统死机解决办法
linux的3种引导方法
vi编辑器使用技巧
Linux使用的一些基本问题
Linux系统下使用wine运行迅雷5的方法
startx启动图形界面失败的几个解决方法
Red Hat Enterprise Linux AS4( 企业版4.0下载)
Raid的学习和基础知识
Linux 下如何配置 PHP 支援 GD

Unix/Linux 中的 DenyHosts 阻止SSH暴力破解最好的方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-01   浏览: 120 ::
收藏到网摘: n/a

我的服务器每天都会有无数的SSH失败尝试记录,有些无聊的人一直不停的扫描,这些人真够无聊的,没事吃饱了撑着,老找些软件在那里穷举扫描,所以大家第一要记的设置一个好的够复杂的密码。

怎么样防,如果要一条一条将这些IP阻止显然治标不治本,还好有DenyHosts软件来代替我们手搞定他。

DenyHosts是Python语言写的一个程序,它会分析sshd的日志文件,当发现重复的攻击时就会记录IP到/etc/hosts.deny文件,从而达到自动屏IP的功能。

DenyHosts官方网站为:http://denyhosts.sourceforge.net

以下是安装记录(以CentOS 4.3, DenyHosts 2.5 为例)

安装

# cd /usr/local/src# wget http://mesh.dl.sourceforge.net/sourceforge/denyhosts/DenyHosts-2.5.tar.gz# tar -zxvf DenyHosts-2.5.tar.gz# cd DenyHosts-2.5# python setup.py install

默认是安装到/usr/share/denyhosts目录的。

配置

# cd /usr/share/denyhosts/# cp denyhosts.cfg-dist denyhosts.cfg# vi denyhosts.cfg

根据自己需要进行相应的配置(解释见下文件的配置文件)

设置启动脚本

# cp daemon-control-dist daemon-control# chown root daemon-control# chmod 700 daemon-control

完了之后执行daemon-contron start就可以了。

# ./daemon-control start

如果要使DenyHosts每次重起后自动启动还需做如下设置:

# cd /etc/init.d# ln -s /usr/share/denyhosts/daemon-control denyhosts# chkconfig –add denyhosts# chkconfig –level 2345 denyhosts on

或者修改/etc/rc.local文件:

# vi /etc/rc.local

加入下面这条命令