掃二維碼與項目經(jīng)理溝通
我們在微信上24小時期待你的聲音
解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流
DenyHosts是Python語言寫的一個程序,它會分析sshd的日志文件(/var/log/secure),當發(fā)現(xiàn)重 復的攻擊時就會記錄IP到/etc/hosts.deny文件,從而達到自動屏IP的功能,下面為大家分享一下centOs下DenyHosts的安裝和使用方法。

[root@localhost ~]# wget http://jaist.dl.sourceforge.net/project/denyhosts/denyhosts/2.6/DenyHosts-2.6.tar.gz
[root@localhost ~]# tar xf DenyHosts-2.6.tar.gz
[root@localhost ~]# cd DenyHosts-2.6
[root@localhost DenyHosts-2.6]# python setup.py install
[root@localhost DenyHosts-2.6]# cp denyhosts.cfg-dist /etc/denyhosts.cfg
[root@localhost DenyHosts-2.6]# cp daemon-control-dist daemon-control
[root@localhost DenyHosts-2.6]# chown root daemon-control
[root@localhost DenyHosts-2.6]# chmod 700 daemon-control
將daemon-control中的#DENYHOSTS_CFG = “/usr/share/denyhosts/denyhosts.cfg”改為 DENYHOSTS_CFG = “/etc/denyhosts.cfg”
啟動
[root@localhost DenyHosts-2.6]# ./daemon-control start(注意相對路徑)
默認允許五次,測試發(fā)現(xiàn)登陸失敗五次之后不允許登陸
[root@localhost ~]# ssh [email protected]
[email protected]'s password: Permission denied, please try again. [email protected]'s password:
Permission denied, please try again.
[email protected]'s password: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). [root@localhost ~]# [root@localhost ~]# ssh [email protected] [email protected]'s password:
Permission denied, please try again.
[email protected]'s password: Permission denied, please try again. [email protected]'s password:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
[root@localhost ~]# ssh [email protected]
[email protected]'s password: Permission denied, please try again. [email protected]'s password:
Permission denied, please try again.
[email protected]'s password: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). [root@localhost ~]# ssh [email protected] [email protected]'s password:
Permission denied, please try again.
[email protected]'s password: Permission denied, please try again. [email protected]'s password:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
[root@localhost ~]# ssh [email protected]
ssh_exchange_identification: read: Connection reset by peer
查看hosts.deny文件
登陸連續(xù)失敗之后就會把ip地址寫在hosts.deny文件 172.16.1.112的ip已經(jīng)被限制,到此功能實現(xiàn)。

我們在微信上24小時期待你的聲音
解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流