{"id":32593,"date":"2026-08-13T10:00:00","date_gmt":"2026-08-13T02:00:00","guid":{"rendered":"https:\/\/cn.hostease.com\/blog\/?p=32593"},"modified":"2026-08-16T19:27:08","modified_gmt":"2026-08-16T11:27:08","slug":"fail2ban-ssh-protection","status":"publish","type":"post","link":"https:\/\/cn.hostease.com\/blog\/guides\/fail2ban-ssh-protection\/","title":{"rendered":"Fail2ban SSH \u9632\u62a4\u914d\u7f6e\uff1a\u4ece\u65e5\u5fd7\u5339\u914d\u5230\u5c01\u7981\u767d\u540d\u5355\u9a8c\u8bc1"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2026\/08\/fail2ban-ssh-protection-cover.webp\" alt=\"Fail2ban SSH \u9632\u62a4\u914d\u7f6e\u5c01\u9762\" loading=\"lazy\" \/><\/p>\n<p>\u8fd9\u7bc7\u6307\u5357\u5e2e\u52a9\u4f60\u914d\u7f6e Fail2ban\uff08\u4e00\u79cd\u81ea\u52a8\u5c01\u7981\u6076\u610f\u767b\u5f55\u7684\u5de5\u5177\uff09\u4fdd\u62a4 SSH\uff08\u5b89\u5168\u8fdc\u7a0b\u767b\u5f55\u534f\u8bae\uff09\u670d\u52a1\uff0c\u4ece\u65e5\u5fd7\u5339\u914d\u89c4\u5219\u5230\u767d\u540d\u5355\u9a8c\u8bc1\uff0c\u907f\u514d\u8bef\u5c01\u6b63\u5e38\u7528\u6237\u3002Fail2ban \u901a\u8fc7\u5206\u6790 SSH \u767b\u5f55\u65e5\u5fd7\u81ea\u52a8\u5c01\u7981\u591a\u6b21\u5931\u8d25\u7684 IP\uff0c\u4f46\u5982\u679c\u914d\u7f6e\u4e0d\u5f53\u53ef\u80fd\u8bef\u5c01\u4f01\u4e1a NAT\uff08\u7f51\u7edc\u5730\u5740\u8f6c\u6362\uff09\u51fa\u53e3\u6216\u81ea\u5df1\u7684 IP\uff0c\u5bfc\u81f4\u65e0\u6cd5\u767b\u5f55\u3002<\/p>\n<p>\u5982\u679c\u4f60\u7684\u670d\u52a1\u5668\u9762\u4e34 SSH \u66b4\u529b\u7834\u89e3\uff0cFail2ban \u662f <a href=\"https:\/\/cn.hostease.com\/blog\/guides\/container-security-hardening\/\">\u5bb9\u5668\u5b89\u5168\u52a0\u56fa<\/a>\u4e4b\u5916\u7684\u7b2c\u4e8c\u9053\u9632\u7ebf\u3002Hostease \u8fd9\u7c7b [VPS](https:\/\/cn.hostease.com\/vps\/)\uff08[\u865a\u62df\u4e13\u7528\u670d\u52a1\u5668](https:\/\/cn.hostease.com\/vps\/)\uff09\u73af\u5883\u4e0a\u7684 SSH \u66b4\u9732\u5728\u516c\u7f51\uff0c\u81ea\u52a8\u5c01\u7981\u6076\u610f\u5c1d\u8bd5\u662f\u57fa\u7840\u9632\u62a4\u3002\u672c\u6587\u91cd\u70b9\u4e0d\u662f Fail2ban \u5b89\u88c5\uff0c\u800c\u662f\u914d\u7f6e\u5c42\u9762\u7684\u907f\u5751\uff1a\u767d\u540d\u5355\u3001\u8fc7\u6ee4\u5668\u548c\u65e5\u5fd7\u89e3\u6790\u3002\u5982\u679c\u4f60\u521a\u5f00\u59cb\u6392\u67e5\u670d\u52a1\u5668\u5b89\u5168\u95ee\u9898\uff0c\u53ef\u4ee5\u53c2\u8003 <a href=\"https:\/\/cn.hostease.com\/blog\/guides\/vps-incident-response-guide\/\">VPS \u5165\u4fb5\u5e94\u6025\u5904\u7406<\/a>\u4e86\u89e3\u6574\u4f53\u5e94\u6025\u6d41\u7a0b\u3002<\/p>\n<h2>\u4e00\u3001\u5b89\u88c5\u4e0e\u521d\u59cb\u914d\u7f6e<\/h2>\n<p>Fail2ban \u5728\u4e3b\u6d41 Linux \u53d1\u884c\u7248\u4e0a\u90fd\u53ef\u4ee5\u76f4\u63a5\u5b89\u88c5\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-linenumbers=\"false\">apt install fail2ban\nsystemctl enable fail2ban\nsystemctl start fail2ban<\/pre>\n<p>\u9ed8\u8ba4\u914d\u7f6e\u6587\u4ef6 \/etc\/fail2ban\/jail.conf \u4f1a\u4f5c\u4e3a\u6a21\u677f\u88ab\u8986\u76d6\uff0c\u4f46\u5b9e\u9645\u751f\u6548\u7684\u662f \/etc\/fail2ban\/jail.local\u3002\u4fee\u6539\u914d\u7f6e\u524d\u5148\u590d\u5236 jail.conf \u5230 jail.local\uff0c\u518d\u8c03\u6574 jail.local\uff0c\u907f\u514d\u5347\u7ea7\u65f6\u4e22\u5931\u81ea\u5b9a\u4e49\u914d\u7f6e\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-linenumbers=\"false\">cp \/etc\/fail2ban\/jail.conf \/etc\/fail2ban\/jail.local<\/pre>\n<p>\u9ed8\u8ba4 jail \u5df2\u7ecf\u542f\u7528\u4e86 SSH \u670d\u52a1\uff0c\u4f46\u53c2\u6570\u6bd4\u8f83\u6fc0\u8fdb\u3002\u751f\u4ea7\u73af\u5883\u9700\u8981\u8c03\u6574 findtime\u3001maxretry\u3001bantime \u4e09\u4e2a\u53c2\u6570\u5339\u914d\u5b9e\u9645\u573a\u666f\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2026\/08\/fail2ban-ssh-protection-flow.webp\" alt=\"Fail2ban \u914d\u7f6e\u4e0e\u5c01\u7981\u6d41\u7a0b\" loading=\"lazy\" \/><\/p>\n<h2>\u4e8c\u3001\u8c03\u6574\u5c01\u7981\u53c2\u6570<\/h2>\n<p>SSH \u767b\u5f55\u5931\u8d25\u68c0\u6d4b\u7684\u6807\u51c6\u8fc7\u6ee4\u5668\u662f sshd\u3002\u914d\u7f6e\u9879\u542b\u4e49\uff1a<\/p>\n<ul>\n<li><strong>findtime<\/strong>\uff1a\u68c0\u6d4b\u7a97\u53e3\u65f6\u95f4\u3002\u9ed8\u8ba4 600 \u79d2\uff0810 \u5206\u949f\uff09\u3002<\/li>\n<li><strong>maxretry<\/strong>\uff1a\u7a97\u53e3\u5185\u6700\u5927\u5931\u8d25\u6b21\u6570\u3002\u9ed8\u8ba4 5 \u6b21\u3002<\/li>\n<li><strong>bantime<\/strong>\uff1a\u5c01\u7981\u65f6\u957f\u3002\u9ed8\u8ba4 600 \u79d2\uff0810 \u5206\u949f\uff09\u3002<\/li>\n<\/ul>\n<p>\u5bf9\u4e8e\u516c\u7f51\u66b4\u9732\u7684\u670d\u52a1\u5668\uff0c\u5efa\u8bae\u628a bantime \u8bbe\u957f\u4e00\u4e9b\uff08\u5982 86400 \u79d2 = 1 \u5929\uff09\uff0c\u8ba9\u88ab\u5c01\u7981\u7684 IP \u653b\u51fb\u8005\u65e0\u6cd5\u5feb\u901f\u91cd\u8bd5\u3002\u4f46\u5bf9\u4e8e\u9891\u7e41\u8bef\u5c01\u573a\u666f\uff08\u5982 NAT \u51fa\u53e3\u88ab\u591a\u4eba\u5171\u4eab\uff09\uff0c\u9700\u8981\u628a maxretry \u63d0\u9ad8\u5230 10 \u6216 20 \u6b21\uff0c\u907f\u514d\u5355\u6b21\u8bef\u64cd\u4f5c\u89e6\u53d1\u5c01\u7981\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-linenumbers=\"false\"># \/etc\/fail2ban\/jail.local\n[sshd]\nenabled = true\nport = ssh\nfilter = sshd\nlogpath = \/var\/log\/auth.log\nmaxretry = 5\nfindtime = 600\nbantime = 86400<\/pre>\n<h2>\u4e09\u3001\u767d\u540d\u5355\u914d\u7f6e<\/h2>\n<p>\u767d\u540d\u5355\u662f\u9632\u6b62\u8bef\u5c01\u7684\u5173\u952e\u914d\u7f6e\u3002\u5728 jail.local \u4e2d\u901a\u8fc7 ignoreip \u8bbe\u7f6e\u59cb\u7ec8\u4fe1\u4efb\u7684 IP\uff0c\u4e0d\u4f1a\u88ab\u5c01\u7981\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-linenumbers=\"false\">ignoreip = 127.0.0.1\/8 192.168.0.0\/16 \u4f60\u7684\u5bb6\u5eadIP \u4f60\u7684\u516c\u53f8IP<\/pre>\n<p>\u9700\u8981\u52a0\u5165\u767d\u540d\u5355\u7684\u573a\u666f\u5305\u62ec\uff1a\u81ea\u5df1\u7684\u529e\u516c IP\uff08\u8fdc\u7a0b\u7ba1\u7406\u670d\u52a1\u5668\uff09\u3001\u516c\u53f8 VPN\uff08\u591a\u4e2a\u540c\u4e8b\u5171\u7528\u51fa\u53e3\uff09\u3001\u76d1\u63a7\u7cfb\u7edf\u7684\u68c0\u67e5 IP\uff08\u9632\u6b62\u76d1\u63a7\u88ab\u8bef\u5c01\uff09\u3001\u81ea\u52a8\u5316\u811a\u672c\u7684\u6267\u884c IP\uff08\u5982 Ansible \u8282\u70b9\uff09\u3002<\/p>\n<p>\u914d\u7f6e\u767d\u540d\u5355\u540e\u5fc5\u987b\u9a8c\u8bc1\u3002\u7528\u6545\u610f\u8f93\u9519\u5bc6\u7801\u7684 SSH \u767b\u5f55\u6d4b\u8bd5\uff0c\u89c2\u5bdf fail2ban.log \u770b\u662f\u5426\u6b63\u786e\u5ffd\u7565\u767d\u540d\u5355 IP\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-linenumbers=\"false\">tail -f \/var\/log\/fail2ban.log\n # \u4ece\u767d\u540d\u5355 IP \u591a\u8f93\u9519\u5bc6\u7801\uff0c\u786e\u8ba4\u6ca1\u88ab\u5c01\u7981\nfail2ban-client status sshd<\/pre>\n<p>\u5982\u679c\u767d\u540d\u5355\u914d\u7f6e\u9519\u8bef\uff0c\u5bf9\u5e94 IP \u5728 maxretry \u540e\u4ecd\u4f1a\u88ab\u5c01\u7981\u3002\u5e38\u89c1\u9519\u8bef\u5305\u62ec CIDR \u683c\u5f0f\u9519\u8bef\uff08\u5982\u6f0f\u5199\u659c\u6760\u4f4d\u6570\uff09\u3001IP \u5199\u9519\uff08\u5982 192.168.1.1 \u5199\u6210 192.168.1.10\uff09\u3002\u914d\u7f6e\u5b8c\u6210\u540e\u7528 fail2ban-client status sshd \u67e5\u770b\u5f53\u524d\u88ab\u5c01\u7981 IP\uff0c\u786e\u8ba4\u767d\u540d\u5355 IP \u4e0d\u5728\u5217\u8868\u91cc\u3002<\/p>\n<h2>\u56db\u3001\u65e5\u5fd7\u89e3\u6790\u89c4\u5219<\/h2>\n<p>fail2ban \u901a\u8fc7\u6b63\u5219\u5339\u914d\u65e5\u5fd7\u8bc6\u522b\u5931\u8d25\u767b\u5f55\u3002\u9ed8\u8ba4\u7684 sshd filter \u9488\u5bf9\u6807\u51c6 syslog \u683c\u5f0f\uff0c\u4f46\u6709\u4e9b SSH \u670d\u52a1\uff08\u5982\u901a\u8fc7 Docker \u8f6c\u53d1\u6216\u81ea\u5b9a\u4e49\u65e5\u5fd7\u683c\u5f0f\uff09\u7684\u65e5\u5fd7\u683c\u5f0f\u53ef\u80fd\u4e0d\u540c\uff0c\u9700\u8981\u8c03\u6574 filter\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-linenumbers=\"false\">fail2ban-regex \/var\/log\/auth.log \/etc\/fail2ban\/filter.d\/sshd.conf<\/pre>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u7edf\u8ba1\u65e5\u5fd7\u4e2d\u5339\u914d\u7684\u5931\u8d25\u767b\u5f55\u6b21\u6570\u548c\u5f53\u524d filter \u80fd\u5426\u8bc6\u522b\u3002\u5982\u679c\u65e5\u5fd7\u683c\u5f0f\u4e0d\u540c\uff0c\u5339\u914d\u6570\u4f1a\u662f 0\uff0c\u9700\u8981\u4fee\u6539 filter \u7684 failregex\u3002\u4fee\u6539\u524d\u5148\u5907\u4efd\u9ed8\u8ba4\u914d\u7f6e\uff0c\u907f\u514d\u5347\u7ea7\u65f6\u4e22\u5931\u3002<\/p>\n<p>SSH \u670d\u52a1\u7684\u65e5\u5fd7\u4f4d\u7f6e\u5728\u4e0d\u540c Linux \u53d1\u884c\u7248\u4e0a\u4e0d\u540c\uff1aDebian\/Ubuntu \u7528 \/var\/log\/auth.log\uff0cCentOS\/RHEL \u7528 \/var\/log\/secure\u3002\u914d\u7f6e fail2ban \u65f6\u8981\u6839\u636e\u7cfb\u7edf\u65e5\u5fd7\u4f4d\u7f6e\u8c03\u6574 logpath\uff0c\u5426\u5219\u4f1a\u627e\u4e0d\u5230\u65e5\u5fd7\u5bfc\u81f4\u6c38\u8fdc\u4e0d\u5c01\u7981\u3002\u53ef\u4ee5\u7528 <code>find \/var\/log -name \"auth*\" -o -name \"secure*\"<\/code> \u786e\u8ba4\u65e5\u5fd7\u6587\u4ef6\u8def\u5f84\u3002\u5bb9\u5668\u5316\u73af\u5883\u5982\u679c SSH \u670d\u52a1\u5728\u5bb9\u5668\u5185\u8fd0\u884c\uff0c\u9700\u8981\u628a\u5bbf\u4e3b\u673a\u7684\u65e5\u5fd7\u901a\u8fc7 volume \u6216\u65e5\u5fd7\u6536\u96c6\u7cfb\u7edf\u8f6c\u53d1\u5230 fail2ban \u80fd\u8bfb\u53d6\u7684\u4f4d\u7f6e\u3002<\/p>\n<p>\u5bf9\u4e8e\u591a IP \u6765\u6e90\u7684\u65e5\u5fd7\uff08\u5982\u7ecf\u8fc7\u8df3\u677f\u673a\u6216\u53cd\u5411\u4ee3\u7406\uff09\uff0c\u65e5\u5fd7\u91cc\u7684\u6e90 IP \u4f1a\u88ab\u66ff\u6362\u4e3a\u8df3\u677f\u673a\u6216\u53cd\u5411\u4ee3\u7406\u7684 IP\u3002fail2ban \u9ed8\u8ba4\u6309\u65e5\u5fd7\u6e90 IP \u5c01\u7981\uff0c\u4f1a\u628a\u6240\u6709\u7ecf\u8fc7\u8df3\u677f\u7684\u771f\u5b9e\u5ba2\u6237\u7aef IP \u90fd\u5c01\u7981\u3002\u89e3\u51b3\u65b9\u6cd5\u662f\u5728 SSH \u670d\u52a1\u7aef\u914d\u7f6e ReversePathFilter \u6216\u5728 fail2ban filter \u4e2d\u901a\u8fc7\u65e5\u5fd7\u4e2d\u7684\u539f\u59cb\u5b57\u6bb5\u63d0\u53d6\u771f\u5b9e IP\u3002\u5982\u679c\u4f60\u505a\u4e86 <a href=\"https:\/\/cn.hostease.com\/blog\/guides\/nginx-limit-req-rate-limiting\/\">Nginx \u9650\u6d41\u914d\u7f6e<\/a>\uff0c\u53cd\u5411\u4ee3\u7406\u5c42\u4f1a\u8f6c\u53d1\u771f\u5b9e IP \u5230\u540e\u7aef SSH \u65e5\u5fd7\uff0c\u4f46 fail2ban \u4ecd\u6309\u65e5\u5fd7\u91cc\u7684\u5b57\u6bb5\u8bfb\u53d6\uff0c\u9700\u8981\u786e\u8ba4\u65e5\u5fd7\u683c\u5f0f\u6b63\u786e\u3002<\/p>\n<p>\u81ea\u5b9a\u4e49 filter \u65f6\u5efa\u8bae\u5148\u5728\u6d4b\u8bd5\u73af\u5883\u9a8c\u8bc1\u6b63\u5219\u5339\u914d\u3002\u7528 fail2ban-regex \u914d\u5408\u5b9e\u9645\u65e5\u5fd7\u6837\u672c\u6d4b\u8bd5\uff0c\u786e\u8ba4 failregex \u80fd\u5339\u914d\u4e0a\u6240\u6709\u5931\u8d25\u767b\u5f55\u4e8b\u4ef6\u3002\u5339\u914d\u89c4\u5219\u8fc7\u4e25\u4f1a\u6f0f\u5c01\u653b\u51fb\u8005\uff0c\u8fc7\u5bbd\u4f1a\u8bef\u5c01\u6b63\u5e38\u767b\u5f55\u3002SSH \u5931\u8d25\u767b\u5f55\u7684\u7279\u5f81\u5173\u952e\u8bcd\u5305\u62ec\uff1aFailed password\u3001Invalid user\u3001Connection closed by authenticating user\u3002\u6bcf\u4e2a\u53d1\u884c\u7248\u7684\u683c\u5f0f\u7565\u6709\u5dee\u5f02\uff0c\u6700\u597d\u628a\u5f53\u524d\u73af\u5883\u7684\u65e5\u5fd7\u6837\u672c\u63d0\u53d6\u51fa\u6765\u4f5c\u4e3a\u6d4b\u8bd5\u8f93\u5165\u3002<\/p>\n<p>\u5982\u679c\u4f60\u505a\u4e86 <a href=\"https:\/\/cn.hostease.com\/blog\/guides\/wordpress-security-hardening\/\">WordPress \u5b89\u5168\u52a0\u56fa<\/a>\uff0cfail2ban \u4e5f\u53ef\u4ee5\u4fdd\u62a4 WordPress \u7684 wp-login.php\uff1a\u901a\u8fc7\u81ea\u5b9a\u4e49 filter \u76d1\u63a7 nginx \u6216 Apache \u8bbf\u95ee\u65e5\u5fd7\uff0c\u5339\u914d wp-login.php \u7684 POST \u5931\u8d25\u8bf7\u6c42\uff0c\u628a\u66b4\u529b\u7834\u89e3\u8005\u52a0\u5165\u4e34\u65f6\u5c01\u7981\u3002\u4f46\u8981\u6ce8\u610f\uff0cHTTP \u5c01\u7981\u7684\u8fc7\u6ee4\u89c4\u5219\u548c SSH \u4e0d\u540c\uff0c\u4e14\u5931\u8d25\u7387\u9ad8\u65f6\u53ef\u80fd\u8bef\u5c01\u641c\u7d22\u5f15\u64ce\u722c\u866b\uff0c\u5efa\u8bae\u8bbe\u7f6e\u8f83\u9ad8\u7684 maxretry\u3002\u5b8c\u6574\u7684 WordPress \u5b89\u5168\u9632\u62a4\u8fd8\u53ef\u4ee5\u53c2\u8003 <a href=\"https:\/\/cn.hostease.com\/blog\/guides\/nginx-limit-req-rate-limiting\/\">Nginx \u9650\u6d41\u914d\u7f6e<\/a>\u5728\u53cd\u5411\u4ee3\u7406\u5c42\u51cf\u5c11\u653b\u51fb\u8bf7\u6c42\uff0c\u5230\u8fbe fail2ban \u4e4b\u524d\u5c31\u88ab\u62e6\u622a\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2026\/08\/fail2ban-ssh-protection-comparison.webp\" alt=\"\u767d\u540d\u5355\u4e0e\u65e5\u5fd7\u89c4\u5219\u5bf9\u6bd4\" loading=\"lazy\" \/><\/p>\n<h2>\u4e94\u3001\u76d1\u63a7\u4e0e\u89e3\u5c01<\/h2>\n<p>Fail2ban \u5c01\u7981\u662f\u4e34\u65f6\u7684\uff0c\u5230\u671f\u4f1a\u81ea\u52a8\u89e3\u5c01\u3002\u5982\u679c\u67d0\u4e2a IP \u8bef\u5c01\u4e86\u4e14\u7b49\u4e0d\u5230\u81ea\u52a8\u89e3\u5c01\uff0c\u53ef\u4ee5\u7528 fail2ban-client \u624b\u52a8\u89e3\u5c01\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"bash\" data-enlighter-linenumbers=\"false\">fail2ban-client set sshd unbanip 192.168.1.100<\/pre>\n<p>\u957f\u671f\u76d1\u63a7\u9700\u8981\u628a fail2ban \u7684\u72b6\u6001\u63a5\u5165\u76d1\u63a7\u5e73\u53f0\u3002\u53ef\u4ee5\u5b9a\u671f\u8fd0\u884c fail2ban-client status sshd\uff0c\u7edf\u8ba1\u88ab\u5c01\u7981 IP \u6570\u91cf\u3001\u5c01\u7981\u89c4\u5219\u89e6\u53d1\u6b21\u6570\u3001\u89e3\u5c01\u6b21\u6570\u3002\u5982\u679c\u67d0\u4e2a IP \u53cd\u590d\u88ab\u5c01\u7981\uff0c\u8bf4\u660e\u8fd9\u662f\u6301\u7eed\u653b\u51fb\u6e90\uff0c\u53ef\u4ee5\u52a0\u5165\u6c38\u4e45\u9ed1\u540d\u5355\u3002<\/p>\n<h2>\u603b\u7ed3<\/h2>\n<p>Fail2ban SSH \u9632\u62a4\u914d\u7f6e\u7684\u6838\u5fc3\u662f\u767d\u540d\u5355\u548c\u65e5\u5fd7\u89e3\u6790\uff1a\u767d\u540d\u5355\u9632\u6b62\u8bef\u5c01\u6b63\u5e38\u7528\u6237\uff0c\u65e5\u5fd7\u89e3\u6790\u786e\u4fdd\u80fd\u8bc6\u522b\u653b\u51fb\u5c1d\u8bd5\u3002\u914d\u7f6e\u5b8c\u6210\u540e\u5fc5\u987b\u9a8c\u8bc1\uff1a\u6545\u610f\u8f93\u9519\u5bc6\u7801\u770b fail2ban.log \u662f\u5426\u6b63\u786e\u5ffd\u7565\u767d\u540d\u5355 IP\uff0c\u7528 fail2ban-regex \u6d4b\u8bd5\u65e5\u5fd7\u89e3\u6790\u89c4\u5219\u3002\u751f\u4ea7\u73af\u5883\u5efa\u8bae bantime \u8bbe\u957f\u4e00\u4e9b\uff08\u5982 24 \u5c0f\u65f6\uff09\uff0c\u8ba9\u653b\u51fb\u8005\u65e0\u6cd5\u5feb\u901f\u91cd\u8bd5\u3002\u540c\u65f6\u5b9a\u671f\u68c0\u67e5\u88ab\u5c01\u7981 IP \u5217\u8868\uff0c\u8bc6\u522b\u6301\u7eed\u653b\u51fb\u6e90\u3002\u5bf9\u4e8e Hostease \u8fd9\u7c7b VPS \u73af\u5883\uff0cFail2ban \u662f SSH \u9632\u62a4\u7684\u57fa\u7840\u5de5\u5177\uff0c\u914d\u5408\u5f3a\u5bc6\u7801\u6216\u5bc6\u94a5\u8ba4\u8bc1\u5f62\u6210\u591a\u5c42\u4fdd\u62a4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7528 Fail2ban \u914d\u7f6e SSH \u9632\u62a4\u65f6\u5982\u4f55\u8bbe\u7f6e\u65e5\u5fd7\u5339\u914d\u548c\u5c01\u7981\u767d\u540d\u5355\uff0c\u907f\u514d\u8bef\u5c01\u6b63\u5e38\u7528\u6237\u3002<\/p>\n","protected":false},"author":2,"featured_media":32590,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3822],"tags":[3197,373,4811,157,4812],"class_list":["post-32593","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-guides","tag-fail2ban","tag-ssh","tag-4811","tag-157","tag-4812"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2026\/08\/fail2ban-ssh-protection-cover.webp","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/posts\/32593","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/comments?post=32593"}],"version-history":[{"count":1,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/posts\/32593\/revisions"}],"predecessor-version":[{"id":32594,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/posts\/32593\/revisions\/32594"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/media\/32590"}],"wp:attachment":[{"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/media?parent=32593"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/categories?post=32593"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/tags?post=32593"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}