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

Unix/Linux
Linux 核心--5.Linux进程
Linux 核心--2.硬件基础
Linux 核心--4.内存管理
以Linux做路由器的问题
Linux 核心--1.前言
Linux 核心--3.软件基础
Automount mini-Howto 文件系统自动挂载程序
对光驱和软驱实现Automount
xf86config使用说明
如何在Linux中设置磁盘限额?
Linux下的各种备份方法汇总
网卡设置指南
Beowulf 中文HOWTO
Sound Blaster AWE 32/64 HOWTO 如何在Linux设定声卡
Linux Remote-Boot mini-HOWTO
Soundblaster 16 PnP Mini-Howto 如何在Linux设定16位P
新闻 Leafsite mini-HOWTO
使用LILO做为Win95+WinNT+Linux多重开机 mini-HOWTO
LINUX modules 模块安装 MINI-HOWTO
Linux + NT OS Loader mini-HOWTO

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-01   浏览: 149 ::
收藏到网摘: 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

加入下面这条命令