首页 > 其他 > 详细

用fail2ban阻止密码尝试攻击

时间:2014-11-22 23:17:20      阅读:387      评论:0      收藏:0      [点我收藏+]

    有些开放外网端口的主机,疯狂的遭遇密码尝试入侵,虽然密码设置的较为复杂,但是长时间的密码尝试会给/var/logs/secure写入大量日志,从而也会增加系统负担。fail2ban就可以很好的解决这个问题,设置最大尝试的次数,当超过指定次数时,fail2ban会调用iptables把尝试探测的IP加入到黑名单,并且锁定一断时间,次数和锁定时间可以根据自己设置,需要启动iptables,以下是一键配置脚本:

#!/bin/bash
#author by thundermeng
#mail:thundermeng@live.cn

#Install fail2ban

wget http://soft.kwx.gd/security/fail2ban-0.8.4.tar.bz2
tar xfj fail2ban-0.8.4.tar.bz2
cd fail2ban-0.8.4
python setup.py install
cd files
cp ./redhat-initd /etc/init.d/fail2ban
chkconfig fail2ban on


#Configuration
sed -i ‘/\[ssh-iptables\]/{n;n;s/enabled  = false/enabled  = true/}‘ /etc/fail2ban/jail.conf
sed -ri ‘/^\[ssh-iptables\]$/,/^\[ssh-ddos\]$/{s#(logpath  =).*#\1 /var/log/secure#}‘ /etc/fail2ban/jail.conf

/etc/init.d/iptables start
/etc/init.d/fail2ban start

fail2ban-client status
iptables -L


本文出自 “Thunder” 博客,请务必保留此出处http://thundermeng.blog.51cto.com/9414441/1581442

用fail2ban阻止密码尝试攻击

原文:http://thundermeng.blog.51cto.com/9414441/1581442

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!