新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
centOs下DenyHosts的安裝和使用方法
DenyHosts是Python語言寫的一個(gè)程序,它會(huì)分析sshd的日志文件(/var/log/secure),當(dāng)發(fā)現(xiàn)重 復(fù)的攻擊時(shí)就會(huì)記錄IP到/etc/hosts.deny文件,從而達(dá)到自動(dòng)屏IP的功能,下面為大家分享一下centOs下DenyHosts的安裝和使用方法。

下載DenyHosts包
[root@localhost ~]# wget http://jaist.dl.sourceforge.net/project/denyhosts/denyhosts/2.6/DenyHosts-2.6.tar.gz
安裝DenyHosts
[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”
啟動(dòng)
[root@localhost DenyHosts-2.6]# ./daemon-control start(注意相對(duì)路徑)
測(cè)試另外一臺(tái)服務(wù)器遠(yuǎn)程連接172.16.1.16
默認(rèn)允許五次,測(cè)試發(fā)現(xiàn)登陸失敗五次之后不允許登陸
[root@localhost ~]# ssh abc@172.16.1.16
abc@172.16.1.16's password: Permission denied, please try again. abc@172.16.1.16's password:
Permission denied, please try again.
abc@172.16.1.16's password: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). [root@localhost ~]# [root@localhost ~]# ssh abc@172.16.1.16 abc@172.16.1.16's password:
Permission denied, please try again.
abc@172.16.1.16's password: Permission denied, please try again. abc@172.16.1.16's password:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
[root@localhost ~]# ssh abc@172.16.1.16
abc@172.16.1.16's password: Permission denied, please try again. abc@172.16.1.16's password:
Permission denied, please try again.
abc@172.16.1.16's password: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). [root@localhost ~]# ssh abc@172.16.1.16 abc@172.16.1.16's password:
Permission denied, please try again.
abc@172.16.1.16's password: Permission denied, please try again. abc@172.16.1.16's password:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
[root@localhost ~]# ssh abc@172.16.1.16
ssh_exchange_identification: read: Connection reset by peer
查看hosts.deny文件
登陸連續(xù)失敗之后就會(huì)把ip地址寫在hosts.deny文件 172.16.1.112的ip已經(jīng)被限制,到此功能實(shí)現(xiàn)。
文章題目:centOs下DenyHosts的安裝和使用方法
轉(zhuǎn)載源于:http://www.dlmjj.cn/article/dpccoii.html


咨詢
建站咨詢
