当你的Linux服务器暴露在互联网之中,该服务器将会遭到互联网上的扫描软件进行扫描,并试图猜测SSH登录口令你会发现,每天会有多条SSH登录失败纪录。那些扫描工具将对你的服务器构成威胁,你必须设置复杂登录口令,并将尝试多次登录失败的IP给阻止掉,让其在一段时间内不能访问该服务器。简单方法也可以修改22端口号.
用DenyHosts可以阻止试图猜测SSH登录口令,它会分析/var/log/secure等日志文件,当发现同一IP在进行多次SSH密码尝试时就会记录IP到/etc/hosts.deny文件,从而达到自动屏蔽该IP的目的。last命令的信息来自/var/log/wtmp,如果对有经验的人可能会删除掉这个。但是还是会留下痕迹,使用nmap命令扫描端口,nmap -PO -sS ip,使用lsof命令,停掉一些不必要的服务,多关注漏洞,配置强有力的iptables来保护自己的系统或者尝试使用Chkrootkit应用程序对rootkit的跟踪,尝试AIDE来检查文件系统的完整性。服务器上除了root外,Linux用户越少越好,如果非要添加就添加shell为nologin。
具体下载目录在 /2012年资料/3月/4/CentOS 6.0安装DenyHosts 2.6总结/
DenyHosts安装
1.下载denyhost官网为:下载到/usr/src目录中,查询一下系统是否符合要求
[root@ denyhosts]# ldd /usr/sbin/sshd|grep libwrap//查看libwrap动态链接库文件。
libwrap.so.0 => /lib/libwrap.so.0 (0x006c8000)
[root@localhost denyhosts]# python -V//查询版本为2.6.5
Python 2.6.5
2.[root@ DenyHosts-2.6]# python setup.py install//安装Denyhost
running install
running build
running build_py
creating build
creating build/lib
creating build/lib/DenyHosts
copying DenyHosts/version.py -> build/lib/DenyHosts
copying DenyHosts/purgecounter.py -> build/lib/DenyHosts
copying DenyHosts/regex.py -> build/lib/DenyHosts
copying DenyHosts/restricted.py -> build/lib/DenyHosts
copying DenyHosts/__init__.py -> build/lib/DenyHosts
copying DenyHosts/old-daemon.py -> build/lib/DenyHosts
copying DenyHosts/python_version.py -> build/lib/DenyHosts
copying DenyHosts/filetracker.py -> build/lib/DenyHosts
copying DenyHosts/plugin.py -> build/lib/DenyHosts
copying DenyHosts/constants.py -> build/lib/DenyHosts
copying DenyHosts/loginattempt.py -> build/lib/DenyHosts
copying DenyHosts/prefs.py -> build/lib/DenyHosts
copying DenyHosts/deny_hosts.py -> build/lib/DenyHosts
copying DenyHosts/lockfile.py -> build/lib/DenyHosts
copying DenyHosts/sync.py -> build/lib/DenyHosts
copying DenyHosts/allowedhosts.py -> build/lib/DenyHosts
copying DenyHosts/daemon.py -> build/lib/DenyHosts
copying DenyHosts/util.py -> build/lib/DenyHosts
copying DenyHosts/counter.py -> build/lib/DenyHosts
copying DenyHosts/denyfileutil.py -> build/lib/DenyHosts
copying DenyHosts/report.py -> build/lib/DenyHosts
running build_scripts
creating build/scripts-2.6
copying and adjusting denyhosts.py -> build/scripts-2.6
changing mode of build/scripts-2.6/denyhosts.py from 644 to 755
running install_lib
creating /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/version.py -> /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/purgecounter.py -> /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/regex.py -> /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/restricted.py -> /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/__init__.py -> /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/old-daemon.py -> /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/python_version.py -> /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/filetracker.py -> /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/plugin.py -> /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/constants.py -> /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/loginattempt.py -> /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/prefs.py -> /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/deny_hosts.py -> /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/lockfile.py -> /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/sync.py -> /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/allowedhosts.py -> /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/daemon.py -> /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/util.py -> /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/counter.py -> /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/denyfileutil.py -> /usr/lib/python2.6/site-packages/DenyHosts
copying build/lib/DenyHosts/report.py -> /usr/lib/python2.6/site-packages/DenyHosts
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/version.py to version.pyc
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/purgecounter.py to purgecounter.pyc
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/regex.py to regex.pyc
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/restricted.py to restricted.pyc
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/__init__.py to __init__.pyc
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/old-daemon.py to old-daemon.pyc
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/python_version.py to python_version.pyc
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/filetracker.py to filetracker.pyc
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/plugin.py to plugin.pyc
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/constants.py to constants.pyc
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/loginattempt.py to loginattempt.pyc
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/prefs.py to prefs.pyc
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/deny_hosts.py to deny_hosts.pyc
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/lockfile.py to lockfile.pyc
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/sync.py to sync.pyc
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/allowedhosts.py to allowedhosts.pyc
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/daemon.py to daemon.pyc
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/util.py to util.pyc
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/counter.py to counter.pyc
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/denyfileutil.py to denyfileutil.pyc
byte-compiling /usr/lib/python2.6/site-packages/DenyHosts/report.py to report.pyc
running install_scripts
copying build/scripts-2.6/denyhosts.py -> /usr/bin
changing mode of /usr/bin/denyhosts.py to 755
running install_data
creating /usr/share/denyhosts//在/usr/share目录创建denyhosts目录
copying denyhosts.cfg-dist -> /usr/share/denyhosts
copying setup.py -> /usr/share/denyhosts
copying daemon-control-dist -> /usr/share/denyhosts
copying CHANGELOG.txt -> /usr/share/denyhosts
copying README.txt -> /usr/share/denyhosts
creating /usr/share/denyhosts/scripts
copying scripts/restricted_from_passwd.py -> /usr/share/denyhosts/scripts
copying scripts/restricted_from_invalid.py -> /usr/share/denyhosts/scripts
creating /usr/share/denyhosts/plugins
copying plugins/README.contrib -> /usr/share/denyhosts/plugins
copying plugins/shorewall_deny.sh -> /usr/share/denyhosts/plugins
copying plugins/test_deny.py -> /usr/share/denyhosts/plugins
copying plugins/shorewall_allow.sh -> /usr/share/denyhosts/plugins
copying LICENSE.txt -> /usr/share/denyhosts
running install_egg_info
Writing /usr/lib/python2.6/site-packages/DenyHosts-2.6-py2.6.egg-info