新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
centOs下DenyHosts的安裝和使用方法
DenyHosts是Python語言寫的一個程序,它會分析sshd的日志文件(/var/log/secure),當發(fā)現(xiàn)重 復的攻擊時就會記錄IP到/etc/hosts.deny文件,從而達到自動屏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”
啟動
[root@localhost DenyHosts-2.6]# ./daemon-control start(注意相對路徑)
測試另外一臺服務器遠程連接172.16.1.16
默認允許五次,測試發(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ù)失敗之后就會把ip地址寫在hosts.deny文件 172.16.1.112的ip已經(jīng)被限制,到此功能實現(xiàn)。
本文名稱:centOs下DenyHosts的安裝和使用方法
文章起源:http://m.5511xx.com/article/dpccoii.html


咨詢
建站咨詢
