linux防暴力破解远程密码神器-fail2ban

安装:fail2ban

[root@xuegod63 ~]# tar  -zxvf fail2ban-0.8.14.tar.gz

[root@xuegod63 fail2ban-0.8.14]# cdfail2ban-0.8.14

查看安装指南README.md

[root@xuegod63 ~]# cdfail2ban-0.8.14

[[email protected]]#python setup.py install

生成服务启动脚本:

[[email protected]]# cp files/redhat-initd /etc/init.d/fail2ban

[[email protected]]# chkconfig --add fail2ban

[[email protected]]# chkconfig  --listfail2ban

fail2ban            0:off       1:off       2:off       3:on 4:on 5:on 6:off

设置条件:ssh远程登录5分钟内3次密码验证失败,禁止用户IP访问主机1小时,1小时该限制自动解除,此IP可以重新登录。

[root@xuegod63 ~]# vim /etc/fail2ban/jail.conf  #改以下红色标记内容

[ssh-iptables]

 

enabled  =true

filter   = sshd

action   = iptables[name=SSH, port=ssh,protocol=tcp]

           sendmail-whois[name=SSH,[email protected], [email protected],sendername="Fail2Ban"]

logpath  = /var/log/secure

findtime  = 300   #需要新添加

maxretry = 3

bantime  = 3600  #需要新添加


启动服务:

[root@xuegod63 fail2ban-0.8.14]#servicefail2ban start

Starting fail2ban:                                         [确定]


测试


查看fail2ban服务运行状态:

[root@xuegod63fail2ban]# fail2ban-clientstatus  #配置好之后我们检测下fail2ban是否工作。

Status

|-Number of jail:  1

`-Jail list:      ssh-iptables

 

[root@xuegod63fail2ban]# fail2ban-client status ssh-iptables 

#具体看某一项的状态也可以看,如果显示被ban的ip和数目就表示成功了,如果都是0,说明没有成功。

Statusfor the jail: ssh-iptables

|-filter

|  |- File list:  /var/log/secure

|  |- Currently failed:   0

|  `- Total failed:   3

`-action

   |- Currently banned:       1

   |  `-IP list:       192.168.1.2

   `- Total banned:      1


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章