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


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