当前位置: 首页 > Linux

使用DenyHosts防止ssh暴力破解

时间:2023-04-06 20:54:07 Linux

DenyHosts是一个用python2.3编写的程序,会分析/var/log/secure等文件,当发现ssh多次登录失败时会写入/etc同一个ip/hosts.dengy文件,达到屏蔽ip的目的。Centos7使用DenyHosts防止ssh暴力破解Centos7使用DenyHosts防止ssh暴力破解下载DenyHosts包[root@localhost~]#wgethttp://jaist.dl.sourceforge.n...安装DenyHosts[root@localhost~]#tarxfDenyHosts-2.6.tar.gz[root@localhost~]#cdDenyHosts-2.6[root@localhostDenyHosts-2.6]#pythonsetup.pyinstallmake配置文件[root@localhostDenyHosts-2.6]#cpdenyhosts.cfg-dist/etc/denyhosts.cfg[root@localhostDenyHosts-2.6]#cpdaemon-control-distdaemon-control[root@localhostDenyHosts-2.6]#chownrootdaemon-control[root@localhostDenyHosts-2.6]#chmod700daemon-control修改配置文件daemon-control中的#DENYHOSTS_CFG="/usr/share/denyhosts/denyhosts.cfg"改为DENYHOSTS_CFG="/etc/denyhosts.cfg"Centos7使用DenyHosts防止ssh暴力破解Centos7使用DenyHosts防止ssh暴力破解start[root@localhostDenyHosts-2.6]#./daemon-controlstart(注意相对路径)测试另一台服务器远程连接172.16.1.16默认允许五次,测试后发现登录失败5次,不允许登录[root@localhost~]#sshabc@172.16.1.16abc@172.16.1.16'spassword:Permissiondenied,pleasetryagain.abc@172.16.1.16's密码:权限被拒绝d、请重试。abc@172.16.1.16的密码:Permissiondenied(publickey,gssapi-keyex,gssapi-with-mic,password).[root@localhost~]#[root@localhost~]#sshabc@172.16.1.16abc@172.16.1.16的密码:权限被拒绝,请重试。abc@172.16.1.16的密码:权限被拒绝,请重试。abc@172.16.1.16的密码:权限被拒绝(publickey,gssapi-keyex,gssapi-with-mic,password).[root@localhost~]#sshabc@172.16.1.16abc@172.16.1.16的密码:权限被拒绝,请重试。abc@172.16.1.16的密码:Permissiondenied,pleasetryagain.abc@172.16.1.16的密码:Permissiondenied(publickey,gssapi-keyex,gssapi-with-mic,password).[root@localhost~]#sshabc@172.16.1.16abc@172.16.1.16的密码:权限被拒绝,请重试。abc@172.16.1.16的密码:权限被拒绝,请重试。abc@172.16.1.16的密码:权限被拒绝(publickey,gssapi-keyex,gssapi-with-mic,密码).[root@localhost~]#sshabc@172.16.1.16ssh_exchange_identification:read:Connectionresetbypeer检查hosts.deny文件连续登录失败后,ip地址会写入hosts.deny文件。Centos7使用DenyHosts来防止ssh暴力破解。Centos7使用DenyHosts来防止ssh暴力破解。172.16.1.112的ip一直被屏蔽限制,直到实现这个功能