Archive for the ‘Linux安全’ Category
Linux 上DenyHosts阻止SSH暴力攻击
现在的互联网非常不安全,很多人没事就拿一些扫描机扫描ssh端口,然后试图连接ssh端口进行暴力破解(穷举扫描),所以建议vps主机的空间,尽量设置复杂的ssh登录密码,使用hosts.deny禁止某些IP访问, 但是功能方面欠缺,如:不能自动屏蔽,那么有什么更好的办法吗,就可以使用denyhosts这款软件了,它会分析/var/log /secure(redhat,Fedora Core)等日志文件,当发现同一IP在进行多次SSH密码尝试时就会记录IP到/etc/hosts.deny文件,从而达到自动屏蔽该IP的目的。 DenyHosts官方网站为:http://denyhosts.sourceforge.net/ 1、下载DenyHosts 并解压 # wget http://soft.vpser.net/security/denyhosts/DenyHosts-2.6.tar.gz # tar zxvf DenyHosts-2.6.tar.gz # cd DenyHosts-2.6 2、安装、配置和启动 # python setup.py install 默认是安装到/usr/share/denyhosts/目录的,进入相应的目录修改配置文件 # cd /usr/share/denyhosts/ # cp denyhosts.cfg-dist denyhosts.cfg # cp daemon-control-dist daemon-control 默认的设置已经可以适合centos系统环境,你们可以使用vi命令查看一下denyhosts.cfg和daemon-control,里面有详细的解释 接着使用下面命令启动denyhosts程序 # chown root daemon-control # chmod 700 daemon-control # ./daemon-control start 如果要使DenyHosts每次重起后自动启动还需做如下设置: # cd /etc/init.d # ln -s /usr/share/denyhosts/daemon-control denyhosts [...]
