#防止暴力破解ssh帐号
#下载安装
cd /dist/dist
wget
tar -zxvf DenyHosts-2.5.tar.gz
cd DenyHosts-2.5
python setup.py install
#默认是安装到/usr/share/denyhosts/目录的。
cd /usr/share/denyhosts/
cp denyhosts.cfg-dist denyhosts.cfg
vi denyhosts.cfg
#---------------------------
#SECURE_LOG = /private/var/log/asl.log
DAEMON_LOG = /var/log/denyhosts
ADMIN_EMAIL = tangliyun2007@gmail.com
SMTP_HOST = smtp.21cn.com
SMTP_PORT = 25
SECURE_LOG = /var/log/secure
#sshd日志文件,它是根据这个文件来判断的,不同的操作系统,文件名稍有不同。
HOSTS_DENY = /etc/hosts.deny
#控制用户登陆的文件
PURGE_DENY = 5m
#过多久后清除已经禁止的
BLOCK_SERVICE = sshd
#禁止的服务名
DENY_THRESHOLD_INVALID = 1
#允许无效用户失败的次数
DENY_THRESHOLD_VALID = 10
#允许普通用户登陆失败的次数
DENY_THRESHOLD_ROOT = 5
#允许root登陆失败的次数
HOSTNAME_LOOKUP=NO
#是否做域名反解
#-----------------------------
cp daemon-control-dist daemon-control
chown root daemon-control
chmod 700 daemon-control
#vi daemon-control
#-----------------------------
DENYHOSTS_BIN = "/usr/bin/denyhosts.py"
DENYHOSTS_LOCK = "/var/lock/subsys/denyhosts"
DENYHOSTS_CFG = "/usr/share/denyhosts/denyhosts.cfg"
#-----------------------------
#完了之后执行daemon-contron start就可以了。
./daemon-control start
ps awx|grep denyhosts
echo "/usr/share/denyhosts/daemon-control start" >> /etc/rc.local
#如果要使DenyHosts每次重起后自动启动还需做如下设置:
# cd /etc/init.d
# ln -s /usr/share/denyhosts/daemon-control denyhosts
# chkconfig --add denyhosts
# chkconfig --level 2345 denyhosts on
阅读(743) | 评论(0) | 转发(0) |