{"id":2049,"date":"2024-07-24T15:16:19","date_gmt":"2024-07-24T07:16:19","guid":{"rendered":"https:\/\/airy.cn\/WordPress\/?p=2049"},"modified":"2024-07-24T17:25:41","modified_gmt":"2024-07-24T09:25:41","slug":"fail2ban-%e7%94%a8%e6%9d%a5%e9%98%b2%e6%ad%a2%e7%b3%bb%e7%bb%9f%e5%85%a5%e4%be%b5%ef%bc%8c%e4%b8%bb%e8%a6%81%e6%98%af%e9%98%b2%e6%ad%a2%e6%9a%b4%e5%8a%9b%e7%a0%b4%e8%a7%a3%e7%b3%bb%e7%bb%9f%e5%af%86","status":"publish","type":"post","link":"https:\/\/airy.cn\/WordPress\/?p=2049","title":{"rendered":"Fail2Ban\uff1a\u53cd\u7cfb\u7edf\u5165\u4fb5\u5229\u5668,\u9632\u6b62\u66b4\u529b\u7834\u89e3SSH\u5bc6\u7801"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"\u7b80\u4ecb\"><\/h2>\n\n\n\n<p>Fail2Ban \u662f\u4e00\u4e2a Linux \u7cfb\u7edf\u7684\u5e94\u7528\u8f6f\u4ef6\uff0c\u7528\u6765\u9632\u6b62\u7cfb\u7edf\u5165\u4fb5\uff0c\u4e3b\u8981\u662f\u9632\u6b62\u66b4\u529b\u7834\u89e3\u7cfb\u7edf\u5bc6\u7801\u3002\u5b83\u662f\u7528 Python \u5f00\u53d1\u7684\u3002<\/p>\n\n\n\n<p>\u53ef\u4ee5\u9632\u6b62\u6709\u4eba\u53cd\u590d\u5c1d\u8bd5 SSH \u5bc6\u7801\u767b\u5f55\uff0c\u4f46\u662f\u5982\u679c SSH \u91c7\u7528\u7684\u662f\u5bc6\u94a5\u767b\u5f55\uff0c\u7981\u6b62\u4e86\u5bc6\u7801\u767b\u5f55\uff0c\u5c31\u4e0d\u9700\u8981 Fail2Ban \u6765\u4fdd\u62a4\u3002<\/p>\n\n\n\n<p>\u5b89\u88c5\u547d\u4ee4\u5982\u4e0b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># ubuntu &amp; Debian\n$ sudo apt install fail2ban\n\n# Fedora\n$ sudo dnf install epel-release\n$ sudo dnf install fail2ban\n\n# Centos &amp; Red hat\n$ yum install fail2ban\n<\/code><\/pre>\n\n\n\n<p>\u5b89\u88c5\u540e\uff0c\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u67e5\u770b Fail2Ban \u7684\u72b6\u6001\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ systemctl status fail2ban.service\n<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u6ca1\u6709\u542f\u52a8\uff0c\u5c31\u542f\u52a8 Fail2Ban\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo systemctl start fail2ban\n<\/code><\/pre>\n\n\n\n<p>\u91cd\u65b0\u542f\u52a8 Fail2Ban\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo systemctl restart fail2ban\n<\/code><\/pre>\n\n\n\n<p>\u8bbe\u7f6e Fail2Ban \u91cd\u542f\u540e\u81ea\u52a8\u8fd0\u884c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo systemctl enable fail2ban\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"fail2ban-client\">fail2ban-client<\/h2>\n\n\n\n<p>Fail2Ban \u81ea\u5e26\u4e00\u4e2a\u5ba2\u6237\u7aef fail2ban-client\uff0c\u7528\u6765\u64cd\u4f5c Fail2Ban\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ fail2ban-client\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u7684\u547d\u4ee4\u4f1a\u8f93\u51fa fail2ban-client \u6240\u6709\u7684\u7528\u6cd5\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u7684\u547d\u4ee4\u67e5\u770b\u6fc0\u6d3b\u7684\u76d1\u63a7\u76ee\u6807\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ fail2ban-client status\n\nStatus\n|- Number of jail:\t1\n`- Jail list:\tsshd\n<\/code><\/pre>\n\n\n\n<p>\u4e0b\u9762\u7684\u547d\u4ee4\u67e5\u770b\u67d0\u4e2a\u76d1\u63a7\u76ee\u6807\uff08\u8fd9\u91cc\u662f sshd\uff09\u7684\u8fd0\u884c\u60c5\u51b5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo fail2ban-client status sshd\n\nStatus for the jail: sshd\n|- Filter\n|  |- Currently failed: 1\n|  |- Total failed:     9\n|  `- Journal matches:  _SYSTEMD_UNIT=sshd.service + _COMM=sshd\n`- Actions\n   |- Currently banned: 1\n   |- Total banned:     1\n   `- Banned IP list:   0.0.0.0\n<\/code><\/pre>\n\n\n\n<p>\u4e0b\u9762\u7684\u547d\u4ee4\u8f93\u51fa\u4e00\u4e2a\u7b80\u8981\u7684\u7248\u672c\uff0c\u5305\u62ec\u6240\u6709\u76d1\u63a7\u76ee\u6807\u88ab\u5c01\u7684 IP \u5730\u5740\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo fail2ban-client banned\n&#91;{'sshd': &#91;'192.168.100.50']}, {'apache-auth': &#91;]}]\n<\/code><\/pre>\n\n\n\n<p>\u4e0b\u9762\u7684\u547d\u4ee4\u53ef\u4ee5\u89e3\u5c01\u67d0\u4e2a IP \u5730\u5740\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo fail2ban-client set sshd unbanip 192.168.1.69\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u914d\u7f6e\">\u914d\u7f6e<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u4e3b\u914d\u7f6e\u6587\u4ef6\">\u4e3b\u914d\u7f6e\u6587\u4ef6<\/h3>\n\n\n\n<p>Fail2Ban \u4e3b\u914d\u7f6e\u6587\u4ef6\u662f\u5728<code>\/etc\/fail2ban\/fail2ban.conf<\/code>\uff0c\u53ef\u4ee5\u65b0\u5efa\u4e00\u4efd\u526f\u672c<code>\/etc\/fail2ban\/fail2ban.local<\/code>\uff0c\u4fee\u6539\u90fd\u9488\u5bf9\u526f\u672c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo cp \/etc\/fail2ban\/fail2ban.conf \/etc\/fail2ban\/fail2ban.local\n<\/code><\/pre>\n\n\n\n<p>\u4e0b\u9762\u662f\u8bbe\u7f6e Fail2Ban \u7684\u65e5\u5fd7\u4f4d\u7f6e\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;Definition]\nlogtarget = \/var\/log\/fail2ban\/fail2ban.log\n<\/code><\/pre>\n\n\n\n<p>\u4fee\u6539\u914d\u7f6e\u4ee5\u540e\uff0c\u9700\u8981\u91cd\u65b0\u542f\u52a8<code>fail2ban.service<\/code>\uff0c\u8ba9\u5176\u751f\u6548\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u5c01\u7981\u914d\u7f6e\">\u5c01\u7981\u914d\u7f6e<\/h3>\n\n\n\n<p>Fail2Ban \u5c01\u7981\u884c\u4e3a\u7684\u914d\u7f6e\u6587\u4ef6\u662f<code>\/etc\/fail2ban\/jail.conf<\/code>\u3002\u4e3a\u4e86\u4fbf\u4e8e\u4fee\u6539\uff0c\u53ef\u4ee5\u628a\u5b83\u590d\u5236\u4e00\u4efd<code>\/etc\/fail2ban\/jail.local<\/code>\uff0c\u540e\u9762\u7684\u4fee\u6539\u90fd\u9488\u5bf9<code>jail.local<\/code>\u8fd9\u4e2a\u6587\u4ef6\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo cp \/etc\/fail2ban\/jail.conf \/etc\/fail2ban\/jail.local\n<\/code><\/pre>\n\n\n\n<p>\u4f60\u4e5f\u53ef\u4ee5\u5728\u76ee\u5f55<code>\/etc\/fail2ban\/jail.d<\/code>\u91cc\u9762\uff0c\u65b0\u5efa\u5355\u72ec\u7684\u5b50\u914d\u7f6e\u6587\u4ef6\uff0c\u6bd4\u5982<code>\/etc\/fail2ban\/jail.d\/sshd.local<\/code>\u3002<\/p>\n\n\n\n<p>\u540c\u6837\u5730\uff0c\u4fee\u6539\u914d\u7f6e\u4ee5\u540e\uff0c\u9700\u8981\u91cd\u65b0\u542f\u52a8<code>fail2ban.service<\/code>\uff0c\u8ba9\u5176\u751f\u6548\u3002<\/p>\n\n\n\n<p>\u914d\u7f6e\u6587\u4ef6\u91cc\u9762\uff0c<code>[DEFAULT]<\/code>\u6807\u9898\u884c\u8868\u793a\u5bf9\u4e8e\u6240\u6709\u5c01\u7981\u76ee\u6807\u751f\u6548\u3002\u4e3e\u4f8b\u6765\u8bf4\uff0c\u5982\u679c\u5c01\u7981\u65f6\u95f4\u4fee\u6539\u4e3a1\u5929\uff0c<code>\/etc\/fail2ban\/jail.local<\/code>\u91cc\u9762\u53ef\u4ee5\u5199\u6210\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;DEFAULT]\nbantime = 1d\n<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u67d0\u4eba\u88ab\u5c01\u65f6\uff0c\u5bf9\u7ad9\u957f\u53d1\u9001\u90ae\u4ef6\u901a\u77e5\uff0c\u53ef\u4ee5\u5982\u4e0b\u8bbe\u7f6e\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;DEFAULT]\ndestemail = yourname@example.com\nsender = yourname@example.com\n\n# to ban &amp; send an e-mail with whois report to the destemail.\naction = %(action_mw)s\n\n# same as action_mw but also send relevant log lines\n#action = %(action_mwl)s\n<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u914d\u7f6e\u5199\u5728\u5176\u4ed6\u6807\u9898\u884c\u4e0b\uff0c\u5c31\u8868\u793a\u53ea\u5bf9\u8be5\u5c01\u7981\u76ee\u6807\u751f\u6548\uff0c\u6bd4\u5982\u5199\u5728<code>[sshd]<\/code>\u4e0b\u9762\uff0c\u5c31\u8868\u793a\u53ea\u5bf9 sshd \u751f\u6548\u3002<\/p>\n\n\n\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cFail2Ban \u5bf9\u5404\u79cd\u670d\u52a1\u90fd\u662f\u5173\u95ed\u7684\uff0c\u5982\u679c\u8981\u9488\u5bf9\u67d0\u4e00\u9879\u670d\u52a1\u5f00\u542f\uff0c\u9700\u8981\u5728\u914d\u7f6e\u6587\u4ef6\u91cc\u9762\u58f0\u660e\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;sshd]\nenabled = true\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u58f0\u660e\u8868\u793a\uff0cFail2Ban \u5bf9 sshd \u5f00\u542f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u914d\u7f6e\u9879\">\u914d\u7f6e\u9879<\/h3>\n\n\n\n<p>\u4e0b\u9762\u662f\u914d\u7f6e\u6587\u4ef6<code>jail.local<\/code>\u7684\u914d\u7f6e\u9879\u542b\u4e49\uff0c\u6240\u6709\u914d\u7f6e\u9879\u7684\u683c\u5f0f\u90fd\u662f<code>key=value<\/code>\u3002<\/p>\n\n\n\n<p>\uff081\uff09bantime<\/p>\n\n\n\n<p>\u5c01\u7981\u7684\u65f6\u95f4\u957f\u5ea6\uff0c\u5355\u4f4d<code>m<\/code>\u8868\u793a\u5206\u949f\uff0c<code>d<\/code>\u8868\u793a\u5929\uff0c\u5982\u679c\u4e0d\u5199\u5355\u4f4d\uff0c\u5219\u8868\u793a\u79d2\u3002Fail2Ban \u9ed8\u8ba4\u5c01\u798110\u5206\u949f\uff0810m \u6216 600\uff09\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;DEFAULT]\nbantime = 10m\n<\/code><\/pre>\n\n\n\n<p>\uff082\uff09findtime<\/p>\n\n\n\n<p>\u767b\u5f55\u5931\u8d25\u8ba1\u7b97\u7684\u65f6\u95f4\u957f\u5ea6\uff0c\u5355\u4f4d<code>m<\/code>\u8868\u793a\u5206\u949f\uff0c<code>d<\/code>\u8868\u793a\u5929\uff0c\u5982\u679c\u4e0d\u5199\u5355\u4f4d\uff0c\u5219\u8868\u793a\u79d2\u3002Fail2Ban \u9ed8\u8ba4\u5c01\u7981 10 \u5206\u949f\u5185\u767b\u5f55 5 \u6b21\u5931\u8d25\u7684\u5ba2\u6237\u7aef\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;DEFAULT]\n\nfindtime = 10m\nmaxretry = 5\n<\/code><\/pre>\n\n\n\n<p>\uff083\uff09maxretry<\/p>\n\n\n\n<p>\u5c1d\u8bd5\u767b\u5f55\u7684\u6700\u5927\u5931\u8d25\u6b21\u6570\u3002<\/p>\n\n\n\n<p>\uff084\uff09destemail<\/p>\n\n\n\n<p>\u63a5\u53d7\u901a\u77e5\u7684\u90ae\u4ef6\u5730\u5740\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;DEFAULT]\ndestemail = root@localhost\nsender = root@&lt;fq-hostname&gt;\nmta = sendmail\n<\/code><\/pre>\n\n\n\n<p>\uff085\uff09sendername<\/p>\n\n\n\n<p>\u901a\u77e5\u90ae\u4ef6\u7684\u201c\u53d1\u4ef6\u4eba\u201d\u5b57\u6bb5\u7684\u503c\u3002<\/p>\n\n\n\n<p>\uff086\uff09mta<\/p>\n\n\n\n<p>\u53d1\u9001\u90ae\u4ef6\u7684\u90ae\u4ef6\u670d\u52a1\uff0c\u9ed8\u8ba4\u662f<code>sendmail<\/code>\u3002<\/p>\n\n\n\n<p>\uff087\uff09action<\/p>\n\n\n\n<p>\u5c01\u7981\u65f6\u91c7\u53d6\u7684\u52a8\u4f5c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;DEFAULT]\naction = $(action_)s\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u7684<code>action_<\/code>\u662f\u9ed8\u8ba4\u52a8\u4f5c\uff0c\u8868\u793a\u62d2\u7edd\u5c01\u7981\u5bf9\u8c61\u7684\u6d41\u91cf\uff0c\u76f4\u5230\u5c01\u7981\u671f\u7ed3\u675f\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u662f Fail2Ban \u63d0\u4f9b\u7684\u4e00\u4e9b\u5176\u4ed6\u52a8\u4f5c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># ban &amp; send an e-mail with whois report to the destemail.\naction_mw = %(action_)s\n            %(mta)s-whois&#91;sender=\"%(sender)s\", dest=\"%(destemail)s\", protocol=\"%(protocol)s\", chain=\"%(chain)s\"]\n\n# ban &amp; send an e-mail with whois report and relevant log lines\n# to the destemail.\naction_mwl = %(action_)s\n             %(mta)s-whois-lines&#91;sender=\"%(sender)s\", dest=\"%(destemail)s\", logpath=\"%(logpath)s\", chain=\"%(chain)s\"]\n\n# See the IMPORTANT note in action.d\/xarf-login-attack for when to use this action\n#\n# ban &amp; send a xarf e-mail to abuse contact of IP address and include relevant log lines\n# to the destemail.\naction_xarf = %(action_)s\n             xarf-login-attack&#91;service=%(__name__)s, sender=\"%(sender)s\", logpath=\"%(logpath)s\", port=\"%(port)s\"]\n\n# ban IP on CloudFlare &amp; send an e-mail with whois report and relevant log lines\n# to the destemail.\naction_cf_mwl = cloudflare&#91;cfuser=\"%(cfemail)s\", cftoken=\"%(cfapikey)s\"]\n                %(mta)s-whois-lines&#91;sender=\"%(sender)s\", dest=\"%(destemail)s\", logpath=\"%(logpath)s\", chain=\"%(chain)s\"]\n<\/code><\/pre>\n\n\n\n<p>\uff088\uff09ignoreip<\/p>\n\n\n\n<p>Fail2Ban \u53ef\u4ee5\u5ffd\u89c6\u7684\u53ef\u4fe1 IP \u5730\u5740\u3002\u591a\u4e2a IP \u5730\u5740\u4e4b\u95f4\u4f7f\u7528\u7a7a\u683c\u5206\u9694\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ignoreip = 127.0.0.1\/8 192.168.1.10 192.168.1.20\n<\/code><\/pre>\n\n\n\n<p>\uff089\uff09port<\/p>\n\n\n\n<p>\u6307\u5b9a\u8981\u76d1\u63a7\u7684\u7aef\u53e3\u3002\u53ef\u4ee5\u8bbe\u4e3a\u4efb\u4f55\u7aef\u53e3\u53f7\u6216\u670d\u52a1\u540d\u79f0\uff0c\u6bd4\u5982<code>ssh<\/code>\u3001<code>22<\/code>\u3001<code>2200<\/code>\u7b49\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"ssh-\u914d\u7f6e\">ssh \u914d\u7f6e<\/h3>\n\n\n\n<p>\u4e0b\u9762\u662f sshd \u7684\u8bbe\u7f6e\u8303\u4f8b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;sshd]\nenabled   = true\nport = ssh\nfilter    = sshd\nbanaction = iptables\nbackend   = systemd\nmaxretry  = 5\nfindtime  = 10m\nbantime   = 1d<\/code><\/pre>\n\n\n\n<p>\u9996\u5148\u9700\u8981\u6ce8\u610f\uff0c\u4e3a\u4e86\u8ba9 Fail2Ban \u80fd\u591f\u5b8c\u6574\u53d1\u6325\u4f5c\u7528\uff0c\u6700\u597d\u5728<code>\/etc\/ssh\/sshd_config<\/code>\u91cc\u9762\u8bbe\u7f6e<code>LogLevel VERBOSE<\/code>\uff0c\u4fdd\u8bc1\u65e5\u5fd7\u6709\u8db3\u591f\u7684\u4fe1\u606f\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>yum install fail2ban -y<br>systemctl enable fail2ban<br>systemctl start fail2ban<br>systemctl status fail2ban.service<br>systemctl restart fail2ban<br>fail2ban-client status<\/p>\n\n\n\n<p>fail2ban-client status sshd<br>fail2ban-client banned<\/p>\n\n\n\n<p>fail2ban-client set sshd unbanip 192.168.0.0<\/p>\n\n\n\n<p>cp \/etc\/fail2ban\/fail2ban.conf \/etc\/fail2ban\/fail2ban.local<br>wget -O \/etc\/fail2ban\/jail.local https:\/\/airy.ltd\/\/fail2ban\/jail.local<\/p>\n\n\n\n<p>cp \/etc\/fail2ban\/jail.conf \/etc\/fail2ban\/jail.local<\/p>\n\n\n\n<p>vi \/etc\/fail2ban\/jail.local<\/p>\n\n\n\n<p><\/p>\n\n\n<p>[DEFAULT]<br \/>\nbantime = 1d<br \/>\nfindtime = 10m<br \/>\nmaxretry = 2<\/p>\n<p>destemail = airy.xu@outlook.com<br \/>\n[sshd]<br \/>\nenabled = true<br \/>\nmode = normal<br \/>\nport = 57022<br \/>\nlogpath = %(sshd_log)s<br \/>\nbackend = %(sshd_backend)s<br \/>\nignoreip = 127.0.0.1\/8 192.168.0.0\/16 172.16.0.0\/12 10.0.0.0\/8<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u66f4\u65b0\u6e90<\/p>\n\n\n\n<p>1.\u5b89\u88c5wget<br>yum install -y wget<br>2.\u5907\u4efd\u670d\u52a1\u5668\u539f\u6709\u7684yum\u6e90\u6587\u4ef6<br>mv \/etc\/yum.repos.d\/CentOS-Base.repo \/etc\/yum.repos.d\/CentOS-Base.repo.backup<\/p>\n\n\n\n<p>3.\u4e0b\u8f7d\u963f\u91cc\u4e91\u955c\u50cf\u6587\u4ef6<\/p>\n\n\n\n<p>sed -i s\/mirror.centos.org\/vault.centos.org\/g \/etc\/yum.repos.d\/<em>.repo sed -i s\/^#.<\/em>baseurl=http\/baseurl=http\/g \/etc\/yum.repos.d\/<em>.repo sed -i s\/^mirrorlist=http\/#mirrorlist=http\/g \/etc\/yum.repos.d\/<\/em>.repo<\/p>\n\n\n\n<p>wget -O \/etc\/yum.repos.d\/Centos-7-Ali.repo http:\/\/mirrors.aliyun.com\/repo\/Centos-7.repo<br>wget -O \/etc\/yum.repos.d\/CentOS-Base.repo http:\/\/mirrors.aliyun.com\/repo\/Centos-7.repo<br>sed -i -e &#8216;\/mirrors.cloud.aliyuncs.com\/d&#8217; -e &#8216;\/mirrors.aliyuncs.com\/d&#8217; \/etc\/yum.repos.d\/Centos-7-Ali.repo<br>sed -i -e &#8216;\/mirrors.cloud.aliyuncs.com\/d&#8217; -e &#8216;\/mirrors.aliyuncs.com\/d&#8217; \/etc\/yum.repos.d\/CentOS-Base.repo<\/p>\n\n\n\n<p>yum-complete-transaction &#8211;cleanup-only<\/p>\n\n\n\n<p>4.\u6e05\u7406\u7f13\u5b58<br>yum clean all<\/p>\n\n\n\n<p>5.\u751f\u6210\u7f13\u5b58<br>yum makecache<\/p>\n\n\n\n<p>6.\u66f4\u65b0\u6700\u65b0\u6e90\u8bbe\u7f6e<br>yum update -y<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Fail2Ban \u662f\u4e00\u4e2a Linux \u7cfb\u7edf\u7684\u5e94\u7528\u8f6f\u4ef6\uff0c\u7528\u6765\u9632\u6b62\u7cfb\u7edf\u5165\u4fb5\uff0c\u4e3b\u8981\u662f\u9632\u6b62\u66b4\u529b\u7834\u89e3\u7cfb\u7edf\u5bc6\u7801\u3002\u5b83\u662f\u7528 P &#8230; <a title=\"Fail2Ban\uff1a\u53cd\u7cfb\u7edf\u5165\u4fb5\u5229\u5668,\u9632\u6b62\u66b4\u529b\u7834\u89e3SSH\u5bc6\u7801\" class=\"read-more\" href=\"https:\/\/airy.cn\/WordPress\/?p=2049\" aria-label=\"\u9605\u8bfb Fail2Ban\uff1a\u53cd\u7cfb\u7edf\u5165\u4fb5\u5229\u5668,\u9632\u6b62\u66b4\u529b\u7834\u89e3SSH\u5bc6\u7801\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kadence_starter_templates_imported_post":false,"footnotes":""},"categories":[2],"tags":[],"class_list":["post-2049","post","type-post","status-publish","format-standard","hentry","category-airy-tech"],"_links":{"self":[{"href":"https:\/\/airy.cn\/WordPress\/index.php?rest_route=\/wp\/v2\/posts\/2049","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/airy.cn\/WordPress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/airy.cn\/WordPress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/airy.cn\/WordPress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/airy.cn\/WordPress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2049"}],"version-history":[{"count":6,"href":"https:\/\/airy.cn\/WordPress\/index.php?rest_route=\/wp\/v2\/posts\/2049\/revisions"}],"predecessor-version":[{"id":2055,"href":"https:\/\/airy.cn\/WordPress\/index.php?rest_route=\/wp\/v2\/posts\/2049\/revisions\/2055"}],"wp:attachment":[{"href":"https:\/\/airy.cn\/WordPress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/airy.cn\/WordPress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2049"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/airy.cn\/WordPress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}