最近使用Ecshop搭建了一个购物平台,可是在添加商品描述的时候碰到了一个图片引用的问题。尤其是添加商品详细描述的时候,通常我们都是去复制其他网站的商品介绍信息,其中顺便也就把图片给复制下来了,可是问题来了?那些图片都是远程引用的,一旦对方改变路径或者防盗链后,那我们看到的可就壮观了(一片叉叉)。那么如何将Ecshop商品描述里面远程引用的图片本地化呢(下载并保存,后引用)?

在ecshop论坛游荡了近半个小时,终于找到了解决方法,新增Ecshop商品描述远程图片本地化插件即可。

使用方法:

第1步、解压附件中的压缩文件,覆盖到 ecshop 的 \includes\fckeditor 目录下。

(这样在后台添加商品的商品详细描述,编辑器最后一个按钮功能就是自动下载远程图片到你的网站空间,这样可防止对方网站图片失效影响到你的网站。)

第2步、设置一下 editor\plugins\savehttpfiles 下的 config.php 文件关于你需要把远程图片保存到你的网站的哪个目录。目录需要有写权限。

(config.php内容如下:您只要将 http://www.****.com 换成您的域名即可)

//设置图片保存绝对路径,如:

$saveFilePath=dirname(__FILE__) . ‘/images’ ;

//设置显示的链接地址,如:

$displayUrl=’http://www.****.com/includes/fckeditor/editor/plugins/savehttpfiles/images’;

到这里就大功告成了,后台测试绝对ok!注意:星月这里下载的附件压缩文件与Ecshop论坛下载的不太一样。Ecshop论坛中提供的插件中有些小问题导致无法正确使用。请下载这里的附件压缩文件覆盖并按步骤操作即可。友情提示:该插件在IE6下无法正常使用,请使用FF。

下载地址:ecshop商品描述远程图片自动本地化插件

(PS:本附件中压缩文件的母本也是来自Ecshop论坛,请尊重版权)

在后台找了半天没有找到域名怎么个转移,原来发现域名转移不在登陆页面,有一个专门的域名管理站,都用了一年lp了居然还不知道。打算国外域名就转到国外的,pp又没有钱,ap上面有,但是又不支持,最后无奈选择enanme,不过也不错,续费才50元。

整个过程也很简单

1. 获取Auth Code

登录LP的域名管理网址manage.opensrs.net,在管理后台,点击“Domain Extras”选项,查看Domain Authorization Information,获取Auth Code。

2. 到ename.cn登记转移

在网站首页有一个域名转入,我是金牌所以续费是50元,不知道别人是不是。然后输入域名,写上转移密码,最后给你发一封邮件,注意是发到你的域名注册时留下的邮箱。

3. 付款与等待

 邮箱确认提交,然后付款,这时会冻结你的续费金额。接下来的日子就是等待了。在转入后,域名在60天内不能转移出去。

  Mysql 4.0及之前的版本是不区分字符集的,全部是latin1,而Mysql4.1之后Mysql支持多语言、多字节。在原来的服务器上使用的GBK编码,直接拷到Mysql 4.0是肯定不能正常运行。

另外,由于Mysql 4.0不支持多语言导致许多汉字在做主键索引是会存在冲突(二进制一直),虽然中间将数据顺利生成了sql语句但不能顺利导入到Mysql 4.0中,几经尝试,发现了一个非常快捷的方式回复BBS的运行:

在PHPMyAdmin中,选中需要到处的数据库,选择“导出”菜单选中需要导出的表,在“Options”组合框的“SQL compatibility mode”选中“MYSQL40”,在“结构”组合框选中“Add IF NOT EXISTS”、“添加 AUTO_INCREMENT 值”、“请在表名及字段名使用引号”,在下面的“导出类型”中选择“REPLACE”,在“另存为文件”组合框中选中“ZIP压缩”,点击“执行”按钮将生成的SQL文件保存到硬盘上。并将这个ZIP文件解压缩,用UltraEdit之类的编辑器打开这个sql文件,检查是否是UTF8编码,如果是则转换成ASCII编码。

将这个SQL文件使用mysql命令程序导入到数据库中即可:mysql -uroot -ppass dbname

这样就可以完成将数据从Mysql 5.0中导入到Mysql 4.0中了。唯一缺陷是会丢失部分数据,原因前面说过在Mysql4.0中不支持多字节语言,许多汉字的二进制一样导致主键冲突。

其实你从4中倒出数据,倒入5,虽然数据库及校验都是utf8的,但你里面的数据却市lantin1的.
你要从5再倒入4的话因为5安装character_set_system 就设置为utf8了,这个你要修改安装程序才能改为其他设置.
所以你要从5倒出数据想默认结果集为latin1的话,可以这样.
/var/mysql/bin/mysqldump --default-character-set=latin1 数据库 数据表 > 备份文件
备份文件中就会出现下面这样的内容
/*!40101 SET NAMES latin1 */;
要是出现
/*!40101 SET NAMES utf8 */;
的话就是把
数据库中的数据做了一次iconv的操作.

使用了hongxiaowan开发的百度新闻插件,但是在浏览最后的生成结果时发现ie中XML文件不能正常显示,即XML文件不能成功解析。仔细查阅hongxiaowan的代码发现,他发布的代码并没有完全遵守百度新闻协议,在百度新闻协议中text标签中是不能包含html代码的。所以需要用strip_tags函数去掉html代码。另外关于他对于category标签和keywords标签均支持不对,当使用了ultimate tag warrior插件时,category标签将文章的tag也加入其中了。

我修改了baidunews函数加入strip_tags,并修改了wp-baidunews.php中关于category标签和keywords标签的生成方法。

hongxiaowan网站关于百度新闻插件网址:http://www.hongxiaowan.com/2006/11/14/the-wordpress-plug-in-of-baidu-news-protocol/

如果需要手工修改,请我提供的代码按照hongxiaowan的页面手工修改。

下载地址:WordPress百度新闻插件(Dominic.Xu 完善版)

BTW: 百度新闻协议站点提交地址:http://news.baidu.com/newsop.html#ks5,上面说不收录博客。试试看吧。提交百度新闻url为http://yoursite/?feed=baidunews或者http://yoursite/wp-baidunews.php,查询XML文件状态URL:http://news.baidu.com/newsop.html#ks6

标签:, , ,

去掉2.7版权的三步骤(注:据供参考,如果出现什么问题,后果自付)

第一步:把 includes\lib_main.php 中的
    $page_title = $GLOBALS['_CFG']['shop_title'] . ' - ' . 'Powered by ECShop';
改为:
   $page_title = $GLOBALS['_CFG']['shop_title'];
====================================
第二步:删除整个 js\common.js 在244行上的 onload = function() 函数
具体的是从:244 至 336 行
====================================
第三步:去掉 themes\default\library\page_footer.lbi 中的输出代码;注:default为你的模板文件
==============去掉以下代码即可==============
{foreach from=$lang.p_y item=pv}{$pv}{/foreach}<br />

具体实现方法:
举例如首页调用方法:
1、先打开index.php文件找到以下代码:
    $smarty->assign('new_articles',    index_get_new_articles());   // 最新文章

在它下面增加以下:
//调用方法

$smarty->assign('class_articles_4',    index_get_class_articles(4,6));   // 分类调用文章
//调用多个就修改传进去的参数,以及模板接收的变量,其中上面的4就是文章分类ID,其中6是调用数量
$smarty->assign('class_articles_5',    index_get_class_articles(5,6));   // 分类调用文章
$smarty->assign('class_articles_6',    index_get_class_articles(6,6));   // 分类调用文章
$smarty->assign('class_articles_7',    index_get_class_articles(7,6));   // 分类调用文章
$smarty->assign('class_articles_8',    index_get_class_articles(8,6));   // 分类调用文章

//在最后?>这个之前增加以下函数

/**
* 获得指定栏目最新的文章列表。
*
* @access  private
* @return  array
*/
function index_get_class_articles($cat_aid, $cat_num)
{
    $sql = "SELECT article_id, title,open_type,cat_id,file_url FROM " .$GLOBALS['ecs']->table('article'). " WHERE cat_id = ".$cat_aid." and is_open = 1 LIMIT " . $cat_num;
    $res = $GLOBALS['db']->getAll($sql);
    $arr = array();
    foreach ($res AS $idx => $row)
    {
        $arr[$idx]['id']          = $row['article_id'];
        $arr[$idx]['title']       = $row['title'];
        $arr[$idx]['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ?
                                        sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title'];
        $arr[$idx]['cat_name']    = $row['cat_name'];
        $arr[$idx]['add_time']    = local_date($GLOBALS['_CFG']['date_format'], $row['add_time']);
        $arr[$idx]['url']         = $row['open_type'] != 1 ?
                                        build_uri('article', array('aid' => $row['article_id']), $row['title']) : trim($row['file_url']);
        $arr[$idx]['cat_url']     = build_uri('article_cat', array('acid' => $row['cat_id']));
    }
    return $arr;
}

2、第二步是在index.dwt模板想调用的地方增加以下代码,(注:以下调上面设置里的分类ID为8的文章列表):

<!--{foreach from=$class_articles_8 item=article}-->
        <li><a href="{$article.url}" title="{$article.title|escape:html}"><!--{$article.short_title|truncate:15:true}--></a></li>
       <!--{/foreach}-->

最近支付宝老显示无权访问,上网问别人,有的人说人品问题,有的说长相问题

到最后有人说证书出了问题,需要重新导入,我照做了还是没用

有人说支付宝账号出了问题,可我也没干嘛啊

后来终于找到了答案,原来跟我使用NOD32杀毒软件有关

不仅支付宝,所有使用SSL的网站都有问题,包括百度空间

在别人指点下找到:NOD32杀毒软件,其中有一项设置是“协议过滤--SSL”,把这个设置改成 “不扫描SSL协议”,支付宝就正常了。

OK,问题解决,开心!

KingCMS 5.0系列版本生成sitemap一直存在错误.现在最新版的KingCMS 5.0.1.0202也出来了,但生成的sitemap还是存在错误,用原程序生成的sitemap提交到GOOGLE管理员工具后,会出现警告,说是时间不正确.原因在于,生成的sitemap的时间格式不正确.

   sitemap中正确的时间应该是这样的

     年:YYYY(2005)
     年和月:YYYY-MM(2005-06)
     年月日:YYYY-MM-DD(2005-06-04)
     年月日小时分钟:YYYY-MM-DDThh:mmTZD(2005-06-04T10:37+08:00)
     年月日小时分钟秒:YYYY-MM-DDThh:mmTZD(2005-06-04T10:37:30+08:00)
     这里需注意的是TZD,TZD指定就是本地时间区域标记,像中国就是+08:00了

您可以浏览一下这篇文章来了解一下Google SiteMap的格式:Google SiteMap的协议格式详细解析

原因找到了,解决方法如下:

修改/page/article/fun.asp的第375行

''outmap=outmap&"<lastmod>"&formatdate(data(0,i),1)&"</lastmod>"

改为

'2008-2-13改
outmap=outmap&"<lastmod>"&formatdate(data(0,i),"yyyy-MM-dd")&"</lastmod>
好了,把修改后的文件传到服务器上,重新生成地图文件,提交

引用:
'2008-2-13改
outmap=outmap&"<lastmod>"&formatdate(data(0,i),"yyyy-MM-dd")&"</lastmod>
好了,把修改后的文件传到服务器上,重新生成地图文件,提交

楼主的代码最后掉了一个双引号 " ,害得我的站出错,把我吓出一身冷汗,这里特意指出来,希望其他的朋友修改时把这个引号添加上去。

不好意思,今天再来补充一下,
建议将/page/article/fun.asp文件也做同样的修改。
----------------------------------------------------------------------
KingCMS 5.0.1.0202版本sitemap修改方法  KingCMS 5.0系列版本用原程序生成的sitemap提交到GOOGLE管理员工具后,会出现警告,说是时间不正确.原因在于,生成的sitemap的时间格式不正确.
sitemap中正确的时间应该是这样的
年:YYYY(2005)
年和月:YYYY-MM(2005-06)
年月日:YYYY-MM-DD(2005-06-04)
年月日小时分钟:YYYY-MM-DDThh:mmTZD(2005-06-04T10:37+08:00)
年月日小时分钟秒:YYYY-MM-DDThh:mmTZD(2005-06-04T10:37:30+08:00)
这里需注意的是TZD,TZD指定就是本地时间区域标记,像中国就是+08:00了
您可以浏览一下这篇文章来了解一下Google SiteMap的格式:Google SiteMap的协议格式详细解析
原因找到了,解决方法如下:
修改/page/article/fun.asp的第375行
''outmap=outmap&"<lastmod>"&formatdate(data(0,i),1)&"</lastmod>"
改为
'2008-2-13改
outmap=outmap&"<lastmod>"&formatdate(data(0,i),"yyyy-MM-dd")&"</lastmod>"
好了,把修改后的文件传到服务器上,重新生成地图文件,提交
----------------------------------------------------------------------
如何让你的KingCMS5.0生成适合google地图的sitemap
原因:时间格式不对.
文件位置:\page\movie\fun.asp找到下面代码

outmap=outmap&"<lastmod>"&formatdate(data(0,i),2)&"</lastmod>"

去除就行了

我的SSH和FTP一直被人扫描,而且还是那种多线程的,导致我的SSH和FTP开启了多进程来应付它的暴力破解,无奈之下还有改了端口了.
不过这是治标不治本的啦,Google一翻,终于给我找到了这个软件DenyHosts,DenyHosts是用Python语言编写的一个程序,它会分析你的日志文件,当发现重复的错误登录时就会记录IP到/etc/hosts.deny文件,然后自动屏蔽IP.功能很不错吧,下面是安装过程 (环境CentOS 5.5, DenyHosts 2.6)

下载:

复制内容到剪贴板

代码:

wget http://imcat.in/down/DenyHosts-2.6.tar.gz

安装:

复制内容到剪贴板

代码:

tar -zxvf DenyHosts-2.6.tar.gz cd DenyHosts-2.6 python setup.py install

修改配置文件:

复制内容到剪贴板

代码:

cp /usr/share/denyhosts/denyhosts.cfg-dist /usr/share/denyhosts/denyhosts.cfg vi /usr/share/denyhosts/denyhosts.cfg

配置文件比较长,需要修改的,我都做了注释,自己看吧

复制内容到剪贴板

代码:

############ THESE SETTINGS ARE REQUIRED #################################################################################### # # SECURE_LOG: the log file that contains sshd logging info # if you are not sure, grep "sshd:" /var/log/* # # The file to process can be overridden with the --file command line # argument # # Redhat or Fedora Core: #日志文件,根据这个文件来判断 SECURE_LOG = /var/log/secure # # Mandrake, FreeBSD or OpenBSD: #SECURE_LOG = /var/log/auth.log # # SuSE: #SECURE_LOG = /var/log/messages # # Mac OS X (v10.4 or greater - #   also refer to:   [url]http://www.denyhosts.net/faq.html#macos[/url] #SECURE_LOG = /private/var/log/asl.log # # Mac OS X (v10.3 or earlier): #SECURE_LOG=/private/var/log/system.log # ######################################################################## ######################################################################## # # HOSTS_DENY: the file which contains restricted host access information # # Most operating systems: #记录屏蔽的IP文件 HOSTS_DENY = /etc/hosts.deny # # Some BSD (FreeBSD) Unixes: #HOSTS_DENY = /etc/hosts.allow # # Another possibility (also see the next option): #HOSTS_DENY = /etc/hosts.evil ####################################################################### ######################################################################## # # PURGE_DENY: removed HOSTS_DENY entries that are older than this time #             when DenyHosts is invoked with the --purge flag # #      format is: i[dhwmy] #      Where 'i' is an integer (eg. 7) #            'm' = minutes #            'h' = hours #            'd' = days #            'w' = weeks #            'y' = years # # never purge: #多久清除屏蔽的IP,我设置一天 PURGE_DENY = 1d # # purge entries older than 1 week #PURGE_DENY = 1w # # purge entries older than 5 days #PURGE_DENY = 5d ####################################################################### ####################################################################### # # PURGE_THRESHOLD: defines the maximum times a host will be purged. # Once this value has been exceeded then this host will not be purged. # Setting this parameter to 0 (the default) disables this feature. # # default: a denied host can be purged/re-added indefinitely #PURGE_THRESHOLD = 0 # # a denied host will be purged at most 2 times. #PURGE_THRESHOLD = 2 # ####################################################################### ####################################################################### # # BLOCK_SERVICE: the service name that should be blocked in HOSTS_DENY # # man 5 hosts_access for details # # eg.   sshd: 127.0.0.1  # will block sshd logins from 127.0.0.1 # # To block all services for the offending host: #BLOCK_SERVICE = ALL # To block only sshd: #禁止的服务,我设置为全部,禁止登录SSH和/FTP BLOCK_SERVICE  = ALL # To only record the offending host and nothing else (if using # an auxilary file to list the hosts).  Refer to: # [url]http://denyhosts.sourceforge.net/faq.html#aux[/url] #BLOCK_SERVICE = # ####################################################################### ####################################################################### # # DENY_THRESHOLD_INVALID: block each host after the number of failed login # attempts has exceeded this value.  This value applies to invalid # user login attempts (eg. non-existent user accounts) # #允许无效用户失败的数次 DENY_THRESHOLD_INVALID = 1 # ####################################################################### ####################################################################### # # DENY_THRESHOLD_VALID: block each host after the number of failed # login attempts has exceeded this value.  This value applies to valid # user login attempts (eg. user accounts that exist in /etc/passwd) except # for the "root" user #允许普通用户失败的次数 DENY_THRESHOLD_VALID = 1 # ####################################################################### ####################################################################### # # DENY_THRESHOLD_ROOT: block each host after the number of failed # login attempts has exceeded this value.  This value applies to # "root" user login attempts only. #允许root用户失败的次数 DENY_THRESHOLD_ROOT = 3 # ####################################################################### ####################################################################### # # DENY_THRESHOLD_RESTRICTED: block each host after the number of failed # login attempts has exceeded this value.  This value applies to # usernames that appear in the WORK_DIR/restricted-usernames file only. # DENY_THRESHOLD_RESTRICTED = 1 # ####################################################################### ####################################################################### # # WORK_DIR: the path that DenyHosts will use for writing data to # (it will be created if it does not already exist). # # Note: it is recommended that you use an absolute pathname # for this value (eg. /home/foo/denyhosts/data) # WORK_DIR = /usr/share/denyhosts/data # ####################################################################### ####################################################################### # # SUSPICIOUS_LOGIN_REPORT_ALLOWED_HOSTS # # SUSPICIOUS_LOGIN_REPORT_ALLOWED_HOSTS=YES|NO # If set to YES, if a suspicious login attempt results from an allowed-host # then it is considered suspicious.  If this is NO, then suspicious logins # from allowed-hosts will not be reported.  All suspicious logins from # ip addresses that are not in allowed-hosts will always be reported. # SUSPICIOUS_LOGIN_REPORT_ALLOWED_HOSTS=YES ###################################################################### ###################################################################### # # HOSTNAME_LOOKUP # # HOSTNAME_LOOKUP=YES|NO # If set to YES, for each IP address that is reported by Denyhosts, # the corresponding hostname will be looked up and reported as well # (if available). #是否做域名反解析 HOSTNAME_LOOKUP=NO # ###################################################################### ###################################################################### # # LOCK_FILE # # LOCK_FILE=/path/denyhosts # If this file exists when DenyHosts is run, then DenyHosts will exit # immediately.  Otherwise, this file will be created upon invocation # and deleted upon exit.  This ensures that only one instance is # running at a time. # # Redhat/Fedora: LOCK_FILE = /var/lock/subsys/denyhosts # # Debian #LOCK_FILE = /var/run/denyhosts.pid # # Misc #LOCK_FILE = /tmp/denyhosts.lock # ###################################################################### ############ THESE SETTINGS ARE OPTIONAL ############ ####################################################################### # # ADMIN_EMAIL: if you would like to receive emails regarding newly # restricted hosts and suspicious logins, set this address to # match your email address.  If you do not want to receive these reports # leave this field blank (or run with the --noemail option) # # Multiple email addresses can be delimited by a comma, eg: # ADMIN_EMAIL = [email]foo@bar.com[/email], [email]bar@foo.com[/email], [email]etc@foobar.com[/email] #管理员Email ADMIN_EMAIL = # ####################################################################### ####################################################################### # # SMTP_HOST and SMTP_PORT: if DenyHosts is configured to email # reports (see ADMIN_EMAIL) then these settings specify the # email server address (SMTP_HOST) and the server port (SMTP_PORT) # # SMTP_HOST = localhost SMTP_PORT = 25 # ####################################################################### ####################################################################### # # SMTP_USERNAME and SMTP_PASSWORD: set these parameters if your # smtp email server requires authentication # #SMTP_USERNAME=foo #SMTP_PASSWORD=bar # ###################################################################### ####################################################################### # # SMTP_FROM: you can specify the "From:" address in messages sent # from DenyHosts when it reports thwarted abuse attempts # SMTP_FROM = DenyHosts &lt;nobody@localhost&gt; # ####################################################################### ####################################################################### # # SMTP_SUBJECT: you can specify the "Subject:" of messages sent # by DenyHosts when it reports thwarted abuse attempts SMTP_SUBJECT = DenyHosts Report # ###################################################################### ###################################################################### # # SMTP_DATE_FORMAT: specifies the format used for the "Date:" header # when sending email messages. # # for possible values for this parameter refer to: man strftime # # the default: # #SMTP_DATE_FORMAT = %a, %d %b %Y %H:%M:%S %z # ###################################################################### ###################################################################### # # SYSLOG_REPORT # # SYSLOG_REPORT=YES|NO # If set to yes, when denied hosts are recorded the report data # will be sent to syslog (syslog must be present on your system). # The default is: NO # #SYSLOG_REPORT=NO # #SYSLOG_REPORT=YES # ###################################################################### ###################################################################### # # ALLOWED_HOSTS_HOSTNAME_LOOKUP # # ALLOWED_HOSTS_HOSTNAME_LOOKUP=YES|NO # If set to YES, for each entry in the WORK_DIR/allowed-hosts file, # the hostname will be looked up.  If your versions of tcp_wrappers # and sshd sometimes log hostnames in addition to ip addresses # then you may wish to specify this option. # #ALLOWED_HOSTS_HOSTNAME_LOOKUP=NO # ###################################################################### ###################################################################### # # AGE_RESET_VALID: Specifies the period of time between failed login # attempts that, when exceeded will result in the failed count for # this host to be reset to 0.  This value applies to login attempts # to all valid users (those within /etc/passwd) with the # exception of root.  If not defined, this count will never # be reset. # # See the comments in the PURGE_DENY section (above) # for details on specifying this value or for complete details # refer to:  [url]http://denyhosts.sourceforge.net/faq.html#timespec[/url] # AGE_RESET_VALID=5d # ###################################################################### ###################################################################### # # AGE_RESET_ROOT: Specifies the period of time between failed login # attempts that, when exceeded will result in the failed count for # this host to be reset to 0.  This value applies to all login # attempts to the "root" user account.  If not defined, # this count will never be reset. # # See the comments in the PURGE_DENY section (above) # for details on specifying this value or for complete details # refer to:  [url]http://denyhosts.sourceforge.net/faq.html#timespec[/url] # AGE_RESET_ROOT=25d # ###################################################################### ###################################################################### # # AGE_RESET_RESTRICTED: Specifies the period of time between failed login # attempts that, when exceeded will result in the failed count for # this host to be reset to 0.  This value applies to all login # attempts to entries found in the WORK_DIR/restricted-usernames file. # If not defined, the count will never be reset. # # See the comments in the PURGE_DENY section (above) # for details on specifying this value or for complete details # refer to:  [url]http://denyhosts.sourceforge.net/faq.html#timespec[/url] # AGE_RESET_RESTRICTED=25d # ###################################################################### ###################################################################### # # AGE_RESET_INVALID: Specifies the period of time between failed login # attempts that, when exceeded will result in the failed count for # this host to be reset to 0.  This value applies to login attempts # made to any invalid username (those that do not appear # in /etc/passwd).  If not defined, count will never be reset. # # See the comments in the PURGE_DENY section (above) # for details on specifying this value or for complete details # refer to:  [url]http://denyhosts.sourceforge.net/faq.html#timespec[/url] # AGE_RESET_INVALID=10d # ###################################################################### ###################################################################### # # RESET_ON_SUCCESS: If this parameter is set to "yes" then the # failed count for the respective ip address will be reset to 0 # if the login is successful. # # The default is RESET_ON_SUCCESS = no # #RESET_ON_SUCCESS = yes # ##################################################################### ###################################################################### # # PLUGIN_DENY: If set, this value should point to an executable # program that will be invoked when a host is added to the # HOSTS_DENY file.  This executable will be passed the host # that will be added as it's only argument. # #PLUGIN_DENY=/usr/bin/true # ###################################################################### ###################################################################### # # PLUGIN_PURGE: If set, this value should point to an executable # program that will be invoked when a host is removed from the # HOSTS_DENY file.  This executable will be passed the host # that is to be purged as it's only argument. # #PLUGIN_PURGE=/usr/bin/true # ###################################################################### ###################################################################### # # USERDEF_FAILED_ENTRY_REGEX: if set, this value should contain # a regular expression that can be used to identify additional # hackers for your particular ssh configuration.  This functionality # extends the built-in regular expressions that DenyHosts uses. # This parameter can be specified multiple times. # See this faq entry for more details: #    [url]http://denyhosts.sf.net/faq.html#userdef_regex[/url] # #USERDEF_FAILED_ENTRY_REGEX= # # ###################################################################### ######### THESE SETTINGS ARE SPECIFIC TO DAEMON MODE  ########## ####################################################################### # # DAEMON_LOG: when DenyHosts is run in daemon mode (--daemon flag) # this is the logfile that DenyHosts uses to report it's status. # To disable logging, leave blank.  (default is: /var/log/denyhosts) # DAEMON_LOG = /var/log/denyhosts # # disable logging: #DAEMON_LOG = # ###################################################################### ####################################################################### # # DAEMON_LOG_TIME_FORMAT: when DenyHosts is run in daemon mode # (--daemon flag) this specifies the timestamp format of # the DAEMON_LOG messages (default is the ISO8061 format: # ie. 2005-07-22 10:38:01,745) # # for possible values for this parameter refer to: man strftime # # Jan 1 13:05:59 #DAEMON_LOG_TIME_FORMAT = %b %d %H:%M:%S # # Jan 1 01:05:59 #DAEMON_LOG_TIME_FORMAT = %b %d %I:%M:%S # ###################################################################### ####################################################################### # # DAEMON_LOG_MESSAGE_FORMAT: when DenyHosts is run in daemon mode # (--daemon flag) this specifies the message format of each logged # entry.  By default the following format is used: # # %(asctime)s - %(name)-12s: %(levelname)-8s %(message)s # # Where the "%(asctime)s" portion is expanded to the format # defined by DAEMON_LOG_TIME_FORMAT # # This string is passed to python's logging.Formatter contstuctor. # For details on the possible format types please refer to: # [url]http://docs.python.org/lib/node357.html[/url] # # This is the default: #DAEMON_LOG_MESSAGE_FORMAT = %(asctime)s - %(name)-12s: %(levelname)-8s %(message)s # # ###################################################################### ####################################################################### # # DAEMON_SLEEP: when DenyHosts is run in daemon mode (--daemon flag) # this is the amount of time DenyHosts will sleep between polling # the SECURE_LOG.  See the comments in the PURGE_DENY section (above) # for details on specifying this value or for complete details # refer to:    [url]http://denyhosts.sourceforge.net/faq.html#timespec[/url] # # DAEMON_SLEEP = 30s # ####################################################################### ####################################################################### # # DAEMON_PURGE: How often should DenyHosts, when run in daemon mode, # run the purge mechanism to expire old entries in HOSTS_DENY # This has no effect if PURGE_DENY is blank. # DAEMON_PURGE = 1h # ####################################################################### #########   THESE SETTINGS ARE SPECIFIC TO     ########## #########       DAEMON SYNCHRONIZATION         ########## ####################################################################### # # Synchronization mode allows the DenyHosts daemon the ability # to periodically send and receive denied host data such that # DenyHosts daemons worldwide can automatically inform one # another regarding banned hosts.   This mode is disabled by # default, you must uncomment SYNC_SERVER to enable this mode. # # for more information, please refer to: #        http:/denyhosts.sourceforge.net/faq.html#sync # ####################################################################### ####################################################################### # # SYNC_SERVER: The central server that communicates with DenyHost # daemons.  Currently, denyhosts.net is the only available server # however, in the future, it may be possible for organizations to # install their own server for internal network synchronization # # To disable synchronization (the default), do nothing. # # To enable synchronization, you must uncomment the following line: #SYNC_SERVER = [url]http://xmlrpc.denyhosts.net:9911[/url] # ####################################################################### ####################################################################### # # SYNC_INTERVAL: the interval of time to perform synchronizations if # SYNC_SERVER has been uncommented.  The default is 1 hour. # #SYNC_INTERVAL = 1h # ####################################################################### ####################################################################### # # SYNC_UPLOAD: allow your DenyHosts daemon to transmit hosts that have # been denied?  This option only applies if SYNC_SERVER has # been uncommented. # The default is SYNC_UPLOAD = yes # #SYNC_UPLOAD = no #SYNC_UPLOAD = yes # ####################################################################### ####################################################################### # # SYNC_DOWNLOAD: allow your DenyHosts daemon to receive hosts that have # been denied by others?  This option only applies if SYNC_SERVER has # been uncommented. # The default is SYNC_DOWNLOAD = yes # #SYNC_DOWNLOAD = no #SYNC_DOWNLOAD = yes # # # ####################################################################### ####################################################################### # # SYNC_DOWNLOAD_THRESHOLD: If SYNC_DOWNLOAD is enabled this parameter # filters the returned hosts to those that have been blocked this many # times by others.  That is, if set to 1, then if a single DenyHosts # server has denied an ip address then you will receive the denied host. # # See also SYNC_DOWNLOAD_RESILIENCY # #SYNC_DOWNLOAD_THRESHOLD = 10 # # The default is SYNC_DOWNLOAD_THRESHOLD = 3 # #SYNC_DOWNLOAD_THRESHOLD = 3 # ####################################################################### ####################################################################### # # SYNC_DOWNLOAD_RESILIENCY:  If SYNC_DOWNLOAD is enabled then the # value specified for this option limits the downloaded data # to this resiliency period or greater. # # Resiliency is defined as the timespan between a hackers first known # attack and it's most recent attack.  Example: # # If the centralized   denyhosts.net server records an attack at 2 PM # and then again at 5 PM, specifying a SYNC_DOWNLOAD_RESILIENCY = 4h # will not download this ip address. # # However, if the attacker is recorded again at 6:15 PM then the # ip address will be downloaded by your DenyHosts instance. # # This value is used in conjunction with the SYNC_DOWNLOAD_THRESHOLD # and only hosts that satisfy both values will be downloaded. # This value has no effect if SYNC_DOWNLOAD_THRESHOLD = 1 # # The default is SYNC_DOWNLOAD_RESILIENCY = 5h (5 hours) # # Only obtain hackers that have been at it for 2 days or more: #SYNC_DOWNLOAD_RESILIENCY = 2d # # Only obtain hackers that have been at it for 5 hours or more: #SYNC_DOWNLOAD_RESILIENCY = 5h # #######################################################################

最后就是设置启动脚本了

复制内容到剪贴板

代码:

cp /usr/share/denyhosts/daemon-control-dist /usr/share/denyhosts/daemon-control chown root /usr/share/denyhosts/daemon-control chmod 755 /usr/share/denyhosts/daemon-control ln -s /usr/share/denyhosts/daemon-control /etc/init.d/denyhosts chkconfig --level 345 denyhosts on

启动denyhosts

复制内容到剪贴板

代码:

service denyhosts start

这样就安装完成了,每次开机都自动启动的,自己测试下,输入几次错误的密码.然后看看cat /etc/hosts.deny 里面是否有屏蔽的IP,再然后测试下,有屏蔽IP是否还能登录SSH和FTP.我的FTP安装的是VSFTP,其他的没测试过..
我的SSH和FTP一直被人扫描,而且还是那种多线程的,导致我的SSH和FTP开启了多进程来应付它的暴力破解,无奈之下还有改了端口了.
不过这是治标不治本的啦,Google一翻,终于给我找到了这个软件DenyHosts,DenyHosts是用Python语言编写的一个程序,它会分析你的日志文件,当发现重复的错误登录时就会记录IP到/etc/hosts.deny文件,然后自动屏蔽IP.功能很不错吧,下面是安装过程 (环境CentOS 5.5, DenyHosts 2.6)

下载:

复制内容到剪贴板

代码:

wget http://imcat.in/down/DenyHosts-2.6.tar.gz

安装:

复制内容到剪贴板

代码:

tar -zxvf DenyHosts-2.6.tar.gz cd DenyHosts-2.6 python setup.py install

修改配置文件:

复制内容到剪贴板

代码:

cp /usr/share/denyhosts/denyhosts.cfg-dist /usr/share/denyhosts/denyhosts.cfg vi /usr/share/denyhosts/denyhosts.cfg

配置文件比较长,需要修改的,我都做了注释,自己看吧

复制内容到剪贴板

代码:

############ THESE SETTINGS ARE REQUIRED #################################################################################### # # SECURE_LOG: the log file that contains sshd logging info # if you are not sure, grep "sshd:" /var/log/* # # The file to process can be overridden with the --file command line # argument # # Redhat or Fedora Core: #日志文件,根据这个文件来判断 SECURE_LOG = /var/log/secure # # Mandrake, FreeBSD or OpenBSD: #SECURE_LOG = /var/log/auth.log # # SuSE: #SECURE_LOG = /var/log/messages # # Mac OS X (v10.4 or greater - #   also refer to:   [url]http://www.denyhosts.net/faq.html#macos[/url] #SECURE_LOG = /private/var/log/asl.log # # Mac OS X (v10.3 or earlier): #SECURE_LOG=/private/var/log/system.log # ######################################################################## ######################################################################## # # HOSTS_DENY: the file which contains restricted host access information # # Most operating systems: #记录屏蔽的IP文件 HOSTS_DENY = /etc/hosts.deny # # Some BSD (FreeBSD) Unixes: #HOSTS_DENY = /etc/hosts.allow # # Another possibility (also see the next option): #HOSTS_DENY = /etc/hosts.evil ####################################################################### ######################################################################## # # PURGE_DENY: removed HOSTS_DENY entries that are older than this time #             when DenyHosts is invoked with the --purge flag # #      format is: i[dhwmy] #      Where 'i' is an integer (eg. 7) #            'm' = minutes #            'h' = hours #            'd' = days #            'w' = weeks #            'y' = years # # never purge: #多久清除屏蔽的IP,我设置一天 PURGE_DENY = 1d # # purge entries older than 1 week #PURGE_DENY = 1w # # purge entries older than 5 days #PURGE_DENY = 5d ####################################################################### ####################################################################### # # PURGE_THRESHOLD: defines the maximum times a host will be purged. # Once this value has been exceeded then this host will not be purged. # Setting this parameter to 0 (the default) disables this feature. # # default: a denied host can be purged/re-added indefinitely #PURGE_THRESHOLD = 0 # # a denied host will be purged at most 2 times. #PURGE_THRESHOLD = 2 # ####################################################################### ####################################################################### # # BLOCK_SERVICE: the service name that should be blocked in HOSTS_DENY # # man 5 hosts_access for details # # eg.   sshd: 127.0.0.1  # will block sshd logins from 127.0.0.1 # # To block all services for the offending host: #BLOCK_SERVICE = ALL # To block only sshd: #禁止的服务,我设置为全部,禁止登录SSH和/FTP BLOCK_SERVICE  = ALL # To only record the offending host and nothing else (if using # an auxilary file to list the hosts).  Refer to: # [url]http://denyhosts.sourceforge.net/faq.html#aux[/url] #BLOCK_SERVICE = # ####################################################################### ####################################################################### # # DENY_THRESHOLD_INVALID: block each host after the number of failed login # attempts has exceeded this value.  This value applies to invalid # user login attempts (eg. non-existent user accounts) # #允许无效用户失败的数次 DENY_THRESHOLD_INVALID = 1 # ####################################################################### ####################################################################### # # DENY_THRESHOLD_VALID: block each host after the number of failed # login attempts has exceeded this value.  This value applies to valid # user login attempts (eg. user accounts that exist in /etc/passwd) except # for the "root" user #允许普通用户失败的次数 DENY_THRESHOLD_VALID = 1 # ####################################################################### ####################################################################### # # DENY_THRESHOLD_ROOT: block each host after the number of failed # login attempts has exceeded this value.  This value applies to # "root" user login attempts only. #允许root用户失败的次数 DENY_THRESHOLD_ROOT = 3 # ####################################################################### ####################################################################### # # DENY_THRESHOLD_RESTRICTED: block each host after the number of failed # login attempts has exceeded this value.  This value applies to # usernames that appear in the WORK_DIR/restricted-usernames file only. # DENY_THRESHOLD_RESTRICTED = 1 # ####################################################################### ####################################################################### # # WORK_DIR: the path that DenyHosts will use for writing data to # (it will be created if it does not already exist). # # Note: it is recommended that you use an absolute pathname # for this value (eg. /home/foo/denyhosts/data) # WORK_DIR = /usr/share/denyhosts/data # ####################################################################### ####################################################################### # # SUSPICIOUS_LOGIN_REPORT_ALLOWED_HOSTS # # SUSPICIOUS_LOGIN_REPORT_ALLOWED_HOSTS=YES|NO # If set to YES, if a suspicious login attempt results from an allowed-host # then it is considered suspicious.  If this is NO, then suspicious logins # from allowed-hosts will not be reported.  All suspicious logins from # ip addresses that are not in allowed-hosts will always be reported. # SUSPICIOUS_LOGIN_REPORT_ALLOWED_HOSTS=YES ###################################################################### ###################################################################### # # HOSTNAME_LOOKUP # # HOSTNAME_LOOKUP=YES|NO # If set to YES, for each IP address that is reported by Denyhosts, # the corresponding hostname will be looked up and reported as well # (if available). #是否做域名反解析 HOSTNAME_LOOKUP=NO # ###################################################################### ###################################################################### # # LOCK_FILE # # LOCK_FILE=/path/denyhosts # If this file exists when DenyHosts is run, then DenyHosts will exit # immediately.  Otherwise, this file will be created upon invocation # and deleted upon exit.  This ensures that only one instance is # running at a time. # # Redhat/Fedora: LOCK_FILE = /var/lock/subsys/denyhosts # # Debian #LOCK_FILE = /var/run/denyhosts.pid # # Misc #LOCK_FILE = /tmp/denyhosts.lock # ###################################################################### ############ THESE SETTINGS ARE OPTIONAL ############ ####################################################################### # # ADMIN_EMAIL: if you would like to receive emails regarding newly # restricted hosts and suspicious logins, set this address to # match your email address.  If you do not want to receive these reports # leave this field blank (or run with the --noemail option) # # Multiple email addresses can be delimited by a comma, eg: # ADMIN_EMAIL = [email]foo@bar.com[/email], [email]bar@foo.com[/email], [email]etc@foobar.com[/email] #管理员Email ADMIN_EMAIL = # ####################################################################### ####################################################################### # # SMTP_HOST and SMTP_PORT: if DenyHosts is configured to email # reports (see ADMIN_EMAIL) then these settings specify the # email server address (SMTP_HOST) and the server port (SMTP_PORT) # # SMTP_HOST = localhost SMTP_PORT = 25 # ####################################################################### ####################################################################### # # SMTP_USERNAME and SMTP_PASSWORD: set these parameters if your # smtp email server requires authentication # #SMTP_USERNAME=foo #SMTP_PASSWORD=bar # ###################################################################### ####################################################################### # # SMTP_FROM: you can specify the "From:" address in messages sent # from DenyHosts when it reports thwarted abuse attempts # SMTP_FROM = DenyHosts &lt;nobody@localhost&gt; # ####################################################################### ####################################################################### # # SMTP_SUBJECT: you can specify the "Subject:" of messages sent # by DenyHosts when it reports thwarted abuse attempts SMTP_SUBJECT = DenyHosts Report # ###################################################################### ###################################################################### # # SMTP_DATE_FORMAT: specifies the format used for the "Date:" header # when sending email messages. # # for possible values for this parameter refer to: man strftime # # the default: # #SMTP_DATE_FORMAT = %a, %d %b %Y %H:%M:%S %z # ###################################################################### ###################################################################### # # SYSLOG_REPORT # # SYSLOG_REPORT=YES|NO # If set to yes, when denied hosts are recorded the report data # will be sent to syslog (syslog must be present on your system). # The default is: NO # #SYSLOG_REPORT=NO # #SYSLOG_REPORT=YES # ###################################################################### ###################################################################### # # ALLOWED_HOSTS_HOSTNAME_LOOKUP # # ALLOWED_HOSTS_HOSTNAME_LOOKUP=YES|NO # If set to YES, for each entry in the WORK_DIR/allowed-hosts file, # the hostname will be looked up.  If your versions of tcp_wrappers # and sshd sometimes log hostnames in addition to ip addresses # then you may wish to specify this option. # #ALLOWED_HOSTS_HOSTNAME_LOOKUP=NO # ###################################################################### ###################################################################### # # AGE_RESET_VALID: Specifies the period of time between failed login # attempts that, when exceeded will result in the failed count for # this host to be reset to 0.  This value applies to login attempts # to all valid users (those within /etc/passwd) with the # exception of root.  If not defined, this count will never # be reset. # # See the comments in the PURGE_DENY section (above) # for details on specifying this value or for complete details # refer to:  [url]http://denyhosts.sourceforge.net/faq.html#timespec[/url] # AGE_RESET_VALID=5d # ###################################################################### ###################################################################### # # AGE_RESET_ROOT: Specifies the period of time between failed login # attempts that, when exceeded will result in the failed count for # this host to be reset to 0.  This value applies to all login # attempts to the "root" user account.  If not defined, # this count will never be reset. # # See the comments in the PURGE_DENY section (above) # for details on specifying this value or for complete details # refer to:  [url]http://denyhosts.sourceforge.net/faq.html#timespec[/url] # AGE_RESET_ROOT=25d # ###################################################################### ###################################################################### # # AGE_RESET_RESTRICTED: Specifies the period of time between failed login # attempts that, when exceeded will result in the failed count for # this host to be reset to 0.  This value applies to all login # attempts to entries found in the WORK_DIR/restricted-usernames file. # If not defined, the count will never be reset. # # See the comments in the PURGE_DENY section (above) # for details on specifying this value or for complete details # refer to:  [url]http://denyhosts.sourceforge.net/faq.html#timespec[/url] # AGE_RESET_RESTRICTED=25d # ###################################################################### ###################################################################### # # AGE_RESET_INVALID: Specifies the period of time between failed login # attempts that, when exceeded will result in the failed count for # this host to be reset to 0.  This value applies to login attempts # made to any invalid username (those that do not appear # in /etc/passwd).  If not defined, count will never be reset. # # See the comments in the PURGE_DENY section (above) # for details on specifying this value or for complete details # refer to:  [url]http://denyhosts.sourceforge.net/faq.html#timespec[/url] # AGE_RESET_INVALID=10d # ###################################################################### ###################################################################### # # RESET_ON_SUCCESS: If this parameter is set to "yes" then the # failed count for the respective ip address will be reset to 0 # if the login is successful. # # The default is RESET_ON_SUCCESS = no # #RESET_ON_SUCCESS = yes # ##################################################################### ###################################################################### # # PLUGIN_DENY: If set, this value should point to an executable # program that will be invoked when a host is added to the # HOSTS_DENY file.  This executable will be passed the host # that will be added as it's only argument. # #PLUGIN_DENY=/usr/bin/true # ###################################################################### ###################################################################### # # PLUGIN_PURGE: If set, this value should point to an executable # program that will be invoked when a host is removed from the # HOSTS_DENY file.  This executable will be passed the host # that is to be purged as it's only argument. # #PLUGIN_PURGE=/usr/bin/true # ###################################################################### ###################################################################### # # USERDEF_FAILED_ENTRY_REGEX: if set, this value should contain # a regular expression that can be used to identify additional # hackers for your particular ssh configuration.  This functionality # extends the built-in regular expressions that DenyHosts uses. # This parameter can be specified multiple times. # See this faq entry for more details: #    [url]http://denyhosts.sf.net/faq.html#userdef_regex[/url] # #USERDEF_FAILED_ENTRY_REGEX= # # ###################################################################### ######### THESE SETTINGS ARE SPECIFIC TO DAEMON MODE  ########## ####################################################################### # # DAEMON_LOG: when DenyHosts is run in daemon mode (--daemon flag) # this is the logfile that DenyHosts uses to report it's status. # To disable logging, leave blank.  (default is: /var/log/denyhosts) # DAEMON_LOG = /var/log/denyhosts # # disable logging: #DAEMON_LOG = # ###################################################################### ####################################################################### # # DAEMON_LOG_TIME_FORMAT: when DenyHosts is run in daemon mode # (--daemon flag) this specifies the timestamp format of # the DAEMON_LOG messages (default is the ISO8061 format: # ie. 2005-07-22 10:38:01,745) # # for possible values for this parameter refer to: man strftime # # Jan 1 13:05:59 #DAEMON_LOG_TIME_FORMAT = %b %d %H:%M:%S # # Jan 1 01:05:59 #DAEMON_LOG_TIME_FORMAT = %b %d %I:%M:%S # ###################################################################### ####################################################################### # # DAEMON_LOG_MESSAGE_FORMAT: when DenyHosts is run in daemon mode # (--daemon flag) this specifies the message format of each logged # entry.  By default the following format is used: # # %(asctime)s - %(name)-12s: %(levelname)-8s %(message)s # # Where the "%(asctime)s" portion is expanded to the format # defined by DAEMON_LOG_TIME_FORMAT # # This string is passed to python's logging.Formatter contstuctor. # For details on the possible format types please refer to: # [url]http://docs.python.org/lib/node357.html[/url] # # This is the default: #DAEMON_LOG_MESSAGE_FORMAT = %(asctime)s - %(name)-12s: %(levelname)-8s %(message)s # # ###################################################################### ####################################################################### # # DAEMON_SLEEP: when DenyHosts is run in daemon mode (--daemon flag) # this is the amount of time DenyHosts will sleep between polling # the SECURE_LOG.  See the comments in the PURGE_DENY section (above) # for details on specifying this value or for complete details # refer to:    [url]http://denyhosts.sourceforge.net/faq.html#timespec[/url] # # DAEMON_SLEEP = 30s # ####################################################################### ####################################################################### # # DAEMON_PURGE: How often should DenyHosts, when run in daemon mode, # run the purge mechanism to expire old entries in HOSTS_DENY # This has no effect if PURGE_DENY is blank. # DAEMON_PURGE = 1h # ####################################################################### #########   THESE SETTINGS ARE SPECIFIC TO     ########## #########       DAEMON SYNCHRONIZATION         ########## ####################################################################### # # Synchronization mode allows the DenyHosts daemon the ability # to periodically send and receive denied host data such that # DenyHosts daemons worldwide can automatically inform one # another regarding banned hosts.   This mode is disabled by # default, you must uncomment SYNC_SERVER to enable this mode. # # for more information, please refer to: #        http:/denyhosts.sourceforge.net/faq.html#sync # ####################################################################### ####################################################################### # # SYNC_SERVER: The central server that communicates with DenyHost # daemons.  Currently, denyhosts.net is the only available server # however, in the future, it may be possible for organizations to # install their own server for internal network synchronization # # To disable synchronization (the default), do nothing. # # To enable synchronization, you must uncomment the following line: #SYNC_SERVER = [url]http://xmlrpc.denyhosts.net:9911[/url] # ####################################################################### ####################################################################### # # SYNC_INTERVAL: the interval of time to perform synchronizations if # SYNC_SERVER has been uncommented.  The default is 1 hour. # #SYNC_INTERVAL = 1h # ####################################################################### ####################################################################### # # SYNC_UPLOAD: allow your DenyHosts daemon to transmit hosts that have # been denied?  This option only applies if SYNC_SERVER has # been uncommented. # The default is SYNC_UPLOAD = yes # #SYNC_UPLOAD = no #SYNC_UPLOAD = yes # ####################################################################### ####################################################################### # # SYNC_DOWNLOAD: allow your DenyHosts daemon to receive hosts that have # been denied by others?  This option only applies if SYNC_SERVER has # been uncommented. # The default is SYNC_DOWNLOAD = yes # #SYNC_DOWNLOAD = no #SYNC_DOWNLOAD = yes # # # ####################################################################### ####################################################################### # # SYNC_DOWNLOAD_THRESHOLD: If SYNC_DOWNLOAD is enabled this parameter # filters the returned hosts to those that have been blocked this many # times by others.  That is, if set to 1, then if a single DenyHosts # server has denied an ip address then you will receive the denied host. # # See also SYNC_DOWNLOAD_RESILIENCY # #SYNC_DOWNLOAD_THRESHOLD = 10 # # The default is SYNC_DOWNLOAD_THRESHOLD = 3 # #SYNC_DOWNLOAD_THRESHOLD = 3 # ####################################################################### ####################################################################### # # SYNC_DOWNLOAD_RESILIENCY:  If SYNC_DOWNLOAD is enabled then the # value specified for this option limits the downloaded data # to this resiliency period or greater. # # Resiliency is defined as the timespan between a hackers first known # attack and it's most recent attack.  Example: # # If the centralized   denyhosts.net server records an attack at 2 PM # and then again at 5 PM, specifying a SYNC_DOWNLOAD_RESILIENCY = 4h # will not download this ip address. # # However, if the attacker is recorded again at 6:15 PM then the # ip address will be downloaded by your DenyHosts instance. # # This value is used in conjunction with the SYNC_DOWNLOAD_THRESHOLD # and only hosts that satisfy both values will be downloaded. # This value has no effect if SYNC_DOWNLOAD_THRESHOLD = 1 # # The default is SYNC_DOWNLOAD_RESILIENCY = 5h (5 hours) # # Only obtain hackers that have been at it for 2 days or more: #SYNC_DOWNLOAD_RESILIENCY = 2d # # Only obtain hackers that have been at it for 5 hours or more: #SYNC_DOWNLOAD_RESILIENCY = 5h # #######################################################################

最后就是设置启动脚本了

复制内容到剪贴板

代码:

cp /usr/share/denyhosts/daemon-control-dist /usr/share/denyhosts/daemon-control chown root /usr/share/denyhosts/daemon-control chmod 755 /usr/share/denyhosts/daemon-control ln -s /usr/share/denyhosts/daemon-control /etc/init.d/denyhosts chkconfig --level 345 denyhosts on

启动denyhosts

复制内容到剪贴板

代码:

service denyhosts start

这样就安装完成了,每次开机都自动启动的,自己测试下,输入几次错误的密码.然后看看cat /etc/hosts.deny 里面是否有屏蔽的IP,再然后测试下,有屏蔽IP是否还能登录SSH和FTP.我的FTP安装的是VSFTP,其他的没测试过..