fail2ban防止暴力破解python
1)下載安裝包github
wget https://github.com/fail2ban/fail2ban/archive/0.8.14.tar.gz && tar -xvzf 0.8.14.tar.gz
2)解壓後查看說明bash
cd fail2ban-0.8.12 cat README.md
3)檢查環境ssh
[root@localhost ~]# python -V Python 2.7.5 [root@localhost ~]# uname -r 3.10.0-693.el7.x86_64
4)安裝tcp
cd fail2ban-0.8.12 python setup.py install
5)生成服務啓動腳本並開機自啓:ide
cp files/redhat-initd /etc/init.d/fail2ban /sbin/chkconfig fail2ban on
6)修改配置 /etc/fail2ban/jail.conf 【enabled = true】測試
[ssh-iptables] # 是否開啓 enabled = true # 過濾規則 filter = sshd # 動做 action = iptables[name=SSH, port=ssh, protocol=tcp] # 日誌文件的路徑 logpath = /var/log/secure # 匹配到的閾值(次數) maxretry = 3
7)啓動日誌
/etc/init.d/fail2ban start
8)測試code
ssh 192.168.10.123
[root@localhost log]# ssh 192.168.10.194 ssh: connect to host 192.168.10.194 port 22: Connection refused