{"id":44152,"date":"2024-10-06T13:18:14","date_gmt":"2024-10-06T05:18:14","guid":{"rendered":"https:\/\/server.hk\/cnblog\/44152\/"},"modified":"2024-10-06T13:18:14","modified_gmt":"2024-10-06T05:18:14","slug":"centos-%e4%b8%8b-denyhosts-%e7%9a%84%e5%ae%89%e8%a3%9d%e5%92%8c%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/44152\/","title":{"rendered":"CentOS \u4e0b DenyHosts \u7684\u5b89\u88dd\u548c\u4f7f\u7528\u65b9\u6cd5"},"content":{"rendered":"<h1 id=\"centos-%e4%b8%8b-denyhosts-%e7%9a%84%e5%ae%89%e8%a3%9d%e5%92%8c%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95-NjQkyhbwEG\">CentOS \u4e0b DenyHosts \u7684\u5b89\u88dd\u548c\u4f7f\u7528\u65b9\u6cd5<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0c\u4f3a\u670d\u5668\u7684\u5b89\u5168\u6027\u8b8a\u5f97\u8d8a\u4f86\u8d8a\u91cd\u8981\u3002\u96a8\u8457\u7db2\u7d61\u653b\u64ca\u7684\u983b\u7e41\u767c\u751f\uff0c\u7279\u5225\u662f\u66b4\u529b\u7834\u89e3 SSH \u767b\u9304\u7684\u653b\u64ca\uff0c\u4fdd\u8b77\u4f3a\u670d\u5668\u514d\u53d7\u672a\u7d93\u6388\u6b0a\u8a2a\u554f\u7684\u5a01\u8105\u8b8a\u5f97\u81f3\u95dc\u91cd\u8981\u3002DenyHosts \u662f\u4e00\u6b3e\u5c08\u70ba Linux \u7cfb\u7d71\u8a2d\u8a08\u7684\u5b89\u5168\u5de5\u5177\uff0c\u80fd\u5920\u6709\u6548\u5730\u9632\u6b62\u9019\u985e\u653b\u64ca\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS \u7cfb\u7d71\u4e0a\u5b89\u88dd\u548c\u4f7f\u7528 DenyHosts\u3002<\/p>\n<h2 id=\"denyhosts-%e7%9a%84%e5%8a%9f%e8%83%bd%e6%a6%82%e8%bf%b0-NjQkyhbwEG\">DenyHosts \u7684\u529f\u80fd\u6982\u8ff0<\/h2>\n<p>DenyHosts \u662f\u4e00\u500b\u7528\u65bc\u9632\u6b62 SSH \u66b4\u529b\u7834\u89e3\u653b\u64ca\u7684\u5de5\u5177\u3002\u5b83\u901a\u904e\u76e3\u63a7 SSH \u767b\u9304\u5617\u8a66\uff0c\u8b58\u5225\u53ef\u7591\u7684 IP \u5730\u5740\uff0c\u4e26\u5c07\u5176\u6dfb\u52a0\u5230\u9632\u706b\u7246\u7684\u9ed1\u540d\u55ae\u4e2d\u3002\u9019\u6a23\u53ef\u4ee5\u6709\u6548\u5730\u6e1b\u5c11\u672a\u7d93\u6388\u6b0a\u7684\u8a2a\u554f\uff0c\u4fdd\u8b77\u4f3a\u670d\u5668\u7684\u5b89\u5168\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9d-denyhosts-NjQkyhbwEG\">\u5b89\u88dd DenyHosts<\/h2>\n<p>\u5728 CentOS \u4e0a\u5b89\u88dd DenyHosts \u7684\u904e\u7a0b\u76f8\u5c0d\u7c21\u55ae\u3002\u4ee5\u4e0b\u662f\u5177\u9ad4\u6b65\u9a5f\uff1a<\/p>\n<ol>\n<li>\u9996\u5148\uff0c\u66f4\u65b0\u7cfb\u7d71\u7684\u8edf\u4ef6\u5305\u5217\u8868\uff1a<\/li>\n<pre><code>sudo yum update<\/code><\/pre>\n<li>\u63a5\u4e0b\u4f86\uff0c\u5b89\u88dd DenyHosts\uff1a<\/li>\n<pre><code>sudo yum install denyhosts<\/code><\/pre>\n<li>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u555f\u52d5 DenyHosts \u670d\u52d9\uff1a<\/li>\n<pre><code>sudo systemctl start denyhosts<\/code><\/pre>\n<li>\u70ba\u4e86\u78ba\u4fdd DenyHosts \u5728\u7cfb\u7d71\u555f\u52d5\u6642\u81ea\u52d5\u555f\u52d5\uff0c\u57f7\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/li>\n<pre><code>sudo systemctl enable denyhosts<\/code><\/pre>\n<\/ol>\n<h2 id=\"%e9%85%8d%e7%bd%ae-denyhosts-NjQkyhbwEG\">\u914d\u7f6e DenyHosts<\/h2>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u6839\u64da\u81ea\u5df1\u7684\u9700\u6c42\u5c0d DenyHosts \u9032\u884c\u4e00\u4e9b\u914d\u7f6e\u3002\u914d\u7f6e\u6587\u4ef6\u4f4d\u65bc \/etc\/denyhosts.conf\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u6587\u672c\u7de8\u8f2f\u5668\u6253\u958b\u8a72\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/denyhosts.conf<\/code><\/pre>\n<p>\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u60a8\u53ef\u4ee5\u8a2d\u7f6e\u4ee5\u4e0b\u5e7e\u500b\u91cd\u8981\u53c3\u6578\uff1a<\/p>\n<ul>\n<li><strong>DENY_THRESHOLD_INVALID<\/strong>: \u8a2d\u7f6e\u7121\u6548\u767b\u9304\u5617\u8a66\u7684\u95be\u503c\uff0c\u8d85\u904e\u6b64\u6578\u91cf\u7684 IP \u5c07\u88ab\u5c01\u9396\u3002<\/li>\n<li><strong>DENY_THRESHOLD_VALID<\/strong>: \u8a2d\u7f6e\u6709\u6548\u767b\u9304\u5617\u8a66\u7684\u95be\u503c\uff0c\u9019\u6709\u52a9\u65bc\u9632\u6b62\u8aa4\u5c01\u3002<\/li>\n<li><strong>HOSTS_DENY<\/strong>: \u8a2d\u7f6e\u8981\u5c01\u9396\u7684 IP \u5730\u5740\u6216\u7db2\u6bb5\u3002<\/li>\n<\/ul>\n<p>\u4fee\u6539\u5b8c\u6210\u5f8c\uff0c\u4fdd\u5b58\u4e26\u9000\u51fa\u7de8\u8f2f\u5668\u3002<\/p>\n<h2 id=\"%e6%9f%a5%e7%9c%8b%e8%a2%ab%e5%b0%81%e9%8e%96%e7%9a%84-ip-%e5%9c%b0%e5%9d%80-NjQkyhbwEG\">\u67e5\u770b\u88ab\u5c01\u9396\u7684 IP \u5730\u5740<\/h2>\n<p>\u60a8\u53ef\u4ee5\u901a\u904e\u67e5\u770b DenyHosts \u7684\u65e5\u8a8c\u6587\u4ef6\u4f86\u6aa2\u67e5\u88ab\u5c01\u9396\u7684 IP \u5730\u5740\u3002\u65e5\u8a8c\u6587\u4ef6\u901a\u5e38\u4f4d\u65bc \/var\/log\/denyhosts\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u65e5\u8a8c\uff1a<\/p>\n<pre><code>cat \/var\/log\/denyhosts\/denyhosts.log<\/code><\/pre>\n<p>\u9019\u5c07\u986f\u793a\u6240\u6709\u88ab DenyHosts \u5c01\u9396\u7684 IP \u5730\u5740\u53ca\u5176\u76f8\u95dc\u4fe1\u606f\u3002<\/p>\n<h2 id=\"%e8%a7%a3%e9%99%a4%e5%b0%81%e9%8e%96-ip-%e5%9c%b0%e5%9d%80-NjQkyhbwEG\">\u89e3\u9664\u5c01\u9396 IP \u5730\u5740<\/h2>\n<p>\u5982\u679c\u60a8\u9700\u8981\u89e3\u9664\u67d0\u500b IP \u5730\u5740\u7684\u5c01\u9396\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo \/usr\/bin\/denyhosts --remove <\/code><\/pre>\n<p>\u5c07  \u66ff\u63db\u70ba\u60a8\u5e0c\u671b\u89e3\u9664\u5c01\u9396\u7684\u5177\u9ad4 IP \u5730\u5740\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-NjQkyhbwEG\">\u7e3d\u7d50<\/h2>\n<p>DenyHosts \u662f\u4e00\u6b3e\u5f37\u5927\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u4fdd\u8b77 CentOS \u4f3a\u670d\u5668\u514d\u53d7 SSH \u66b4\u529b\u7834\u89e3\u653b\u64ca\u3002\u901a\u904e\u7c21\u55ae\u7684\u5b89\u88dd\u548c\u914d\u7f6e\uff0c\u60a8\u53ef\u4ee5\u986f\u8457\u63d0\u9ad8\u4f3a\u670d\u5668\u7684\u5b89\u5168\u6027\u3002\u5c0d\u65bc\u9700\u8981\u9ad8\u5b89\u5168\u6027\u7684\u74b0\u5883\uff0c\u5efa\u8b70\u4f7f\u7528 DenyHosts \u4f86\u52a0\u5f37\u9632\u8b77\u3002<\/p>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u53ef\u9760\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2f VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\uff0c\u6eff\u8db3\u4e0d\u540c\u7528\u6236\u7684\u9700\u6c42\u3002\u7121\u8ad6\u662f\u500b\u4eba\u7db2\u7ad9\u9084\u662f\u4f01\u696d\u61c9\u7528\uff0c\u6211\u5011\u7684 <a href=\"https:\/\/server.hk\">\u4f3a\u670d\u5668<\/a> \u90fd\u80fd\u70ba\u60a8\u63d0\u4f9b\u7a69\u5b9a\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3\u5982\u4f55\u5728 CentOS \u4e0a\u5b89\u88dd\u548c\u4f7f\u7528 DenyHosts\uff0c\u6709\u6548\u9632\u6b62 SSH \u66b4\u529b\u7834\u89e3\u653b\u64ca\uff0c\u63d0\u5347\u7cfb\u7d71\u5b89\u5168\u6027\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-44152","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44152","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=44152"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44152\/revisions"}],"predecessor-version":[{"id":44153,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44152\/revisions\/44153"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=44152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=44152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=44152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}