denyhosts是python語言寫的乙個程式,它會分析sshd的日誌檔案(/var/log/secure),當發現重 復的攻擊時就會記錄ip到/etc/hosts.deny檔案,從而達到自動屏ip的功能
denyhosts官方**
1
2
3
4
5
tar
-xzf denyhosts-2.6.
tar
.gz
cd
denyhosts-2.6
python setup.py
install
cd
/usr/share/denyhosts/
#安裝目錄
cp
denyhosts.cfg-dist denyhosts.cfg
vim denyhosts.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
############ these settings are required ############
secure_log =
/var/log/secure
#系統的ssh日誌,centos預設是這個檔案
hosts_deny =
/etc/hosts
.deny
#被阻止ip的文件
purge_deny = 2d
#阻止時間
block_service = sshd
deny_threshold_invalid = 5
#允許無效使用者登入失敗的次數
deny_threshold_valid = 10
#允許普通使用者登入失敗的次數
deny_threshold_root = 3
#允許root登入失敗的次數
deny_threshold_restricted = 3
#設定 deny host 寫入到該資料夾
work_dir =
/usr/share/denyhosts/data
#將deny的host或ip紀錄到work_dir中
suspicious_login_report_allowed_hosts=yes
hostname_lookup=yes
#是否做網域名稱反解
lock_file =
/var/lock/subsys/denyhosts
############ these settings are optional ############
admin_email = [email protected]
smtp_host = localhost
smtp_port = 25
smtp_from = denyhosts
smtp_subject = denyhosts report
age_reset_valid=5d
age_reset_root=25d
age_reset_restricted=25d
age_reset_invalid=10d
######### these settings are specific to daemon mode ##########
daemon_log =
/var/log/denyhosts
#denyhosts自己的日誌
daemon_sleep = 30s
daemon_purge = 1h
1
2
3
4
5
6
cp
daemon-control-dist daemon-control
chown
root daemon-control
chmod
700 daemon-control
.
/daemon-control
start
ln
-s
/usr/share/denyhosts/daemon-control
/etc/init
.d
/denyhosts
chkconfig --level 2345 denyhosts on
1
2
#重啟服務以及程序
service denyhosts restart
1
2
sent denyhosts sigterm
starting denyhosts:
/usr/bin/env
python
/usr/bin/denyhosts
.py --daemon --config=
/usr/share/denyhosts/denyhosts
.cfg
cat /etc/hosts.deny #檢視阻止的ip 記錄
如果取消這個ip的限制,則在/etc/hosts.deny刪除ip資訊
Nginx加固 Tomcat加固
二 tomcat加固 nginx禁止顯示版本有兩種方法 vim usr local nginx conf nginx.conf server tokens off src core nginx.h define nginx version 1.9.15 define nginx ver nginx ...
DenyHosts 防止SSH爆破
denyhosts 官方 為 一 檢查安裝條件 ldd usr sbin sshd libwrap.so.0 usr lib libwrap.so.0 0x0046e000 2 判斷預設安裝的python版本 root localhost 03 python v python 2.4.3 cento...
DenyHosts安全防護
一,關於安裝核修改配置檔案 denyhosts官網 2.解壓安裝並備份乙份配置 root www tar zxvf denyhosts 2.6.tar.gz root www cd denyhosts 2.6 root www denyhosts 2.6 yum install python y r...