{"id":989,"date":"2020-12-11T23:45:48","date_gmt":"2020-12-11T15:45:48","guid":{"rendered":"<!-- wp:paragraph -->\n<p>\u4eca\u5929\u4e0b\u5348\uff0c\u6253\u5f00\u535a\u5ba2\u7684\u65f6\u5019\u5f88\u5361\uff0c\u9875\u9762\u63d0\u793a\u6570\u636e\u5e93\u9519\u8bef\u6216\u8005\u670d\u52a1\u5668\u8d1f\u8f7d\u8fc7\u9ad8\u3002<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>\u6253\u5f00VPS\u540e\u53f0\uff0c\u53d1\u73b0CPU\u548c\u78c1\u76d8\u8d1f\u8f7d\u5f88\u9ad8\u3002<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:image {\"id\":990,\"sizeSlug\":\"large\",\"linkDestination\":\"none\"} -->\n<figure class=\"wp-b"},"modified":"2020-12-11T23:49:28","modified_gmt":"2020-12-11T15:49:28","slug":"%e9%81%ad%e9%81%87%e5%88%b0%e4%ba%86ssh%e6%9a%b4%e5%8a%9b%e7%a0%b4%e8%a7%a3%e6%94%bb%e5%87%bb","status":"publish","type":"post","link":"https:\/\/blog.francis67.cc\/?p=989","title":{"rendered":"\u906d\u9047\u5230\u4e86SSH\u66b4\u529b\u7834\u89e3\u653b\u51fb"},"content":{"rendered":"\n<p>\u4eca\u5929\u4e0b\u5348\uff0c\u6253\u5f00\u535a\u5ba2\u7684\u65f6\u5019\u5f88\u5361\uff0c\u9875\u9762\u63d0\u793a\u6570\u636e\u5e93\u9519\u8bef\u6216\u8005\u670d\u52a1\u5668\u8d1f\u8f7d\u8fc7\u9ad8\u3002<\/p>\n\n\n\n<p>\u6253\u5f00VPS\u540e\u53f0\uff0c\u53d1\u73b0CPU\u548c\u78c1\u76d8\u8d1f\u8f7d\u5f88\u9ad8\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"820\" height=\"985\" src=\"https:\/\/blog.francis67.cc\/wp-content\/uploads\/2020\/12\/FireShot-Capture-015-Manage-155.138.202.156-Vultr.com-my.vultr_.com_.png\" alt=\"\" class=\"wp-image-990\" srcset=\"https:\/\/blog.francis67.cc\/wp-content\/uploads\/2020\/12\/FireShot-Capture-015-Manage-155.138.202.156-Vultr.com-my.vultr_.com_.png 820w, https:\/\/blog.francis67.cc\/wp-content\/uploads\/2020\/12\/FireShot-Capture-015-Manage-155.138.202.156-Vultr.com-my.vultr_.com_-250x300.png 250w, https:\/\/blog.francis67.cc\/wp-content\/uploads\/2020\/12\/FireShot-Capture-015-Manage-155.138.202.156-Vultr.com-my.vultr_.com_-768x923.png 768w, https:\/\/blog.francis67.cc\/wp-content\/uploads\/2020\/12\/FireShot-Capture-015-Manage-155.138.202.156-Vultr.com-my.vultr_.com_-624x750.png 624w\" sizes=\"auto, (max-width: 820px) 100vw, 820px\" \/><\/figure>\n\n\n\n<p>\u7136\u540e\u4f7f\u7528Xshell\u767b\u5f55\u67e5\u770b\uff0c\u63d0\u793a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Last failed login: Fri Dec 11 23:14:56 CST 2020 from 221.131.165.85 on ssh:notty<br>There were 26 failed login attempts since the last successful login.<\/pre>\n\n\n\n<p>\u610f\u8bc6\u5230\u53ef\u80fd\u906d\u5230\u653b\u51fb\uff0c\u67e5\u770bssh\u767b\u5f55\u65e5\u5fd7<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cat \/var\/log\/secure |more<\/pre>\n\n\n\n<p>\u7b2c\u4e00\u6b65\uff0c\u5148\u4f7f\u7528\u5c01IP\u7684\u65b9\u6cd5\uff0c\u5c06\u53ef\u7591\u7684IP\u6dfb\u52a0\u5230 \/etc\/hosts.deny  \u4e2d<\/p>\n\n\n\n<p>\u7b2c\u4e8c\u6b65\uff0c\u5b89\u88c5 <a href=\"https:\/\/github.com\/fail2ban\/fail2ban\" target=\"_blank\" rel=\"noreferrer noopener\">Fail2ban <\/a>\u8f85\u52a9\u5c01IP\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">yum install epel-release <br>yum install fail2ban -y<br># \u5b89\u88c5fail2ban \u5b8c\u6210\u540e<br>systemctl enable fail2ban # \u8bbe\u7f6efail2ban\u5f00\u673a\u542f\u52a8 <br>systemctl start fail2ban # \u542f\u52a8fail2ban <br>systemctl status fail2ban # \u67e5\u770bfail2ban\u7684\u8fd0\u884c\u72b6\u6001<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">cp \/etc\/fail2ban\/jail.conf \/etc\/fail2ban\/jail.local<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">vim \/etc\/fail2ban\/jail.local<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">[sshd]\nenabled = true\nfilter = sshd\naction = iptables[name=sshd,port=22,protocol=tcp]\nmaxretry = 3\nfindtime = 60\nbantime = 7200\nlogpath = \/var\/log\/secure<\/pre>\n\n\n\n<p>\u5b89\u88c5\u548c\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u4f7f\u7528\u547d\u4ee4\u67e5\u770b\uff0c\u4e00\u4f1a\u513f\u4e0d\u5230\u4e00\u4e2a\u5c0f\u65f6\u7684\u65f6\u95f4\uff0c\u53c8\u88ab\u5c1d\u8bd5\u4e86\u8fd9\u4e48\u591a\u6b21\uff0c\u8fd8\u6709\u8fd9\u4e48\u591a\u4e0d\u540c\u7684IP\uff0c\u662f\u88ab\u8c01\u76ef\u4e0a\u4e86\u5417\uff1f<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">>> fail2ban-client status sshd\nStatus for the jail: sshd\n|- Filter\n| |- Currently failed: 10\n| |- Total failed: 157\n| <code>- Journal matches: _SYSTEMD_UNIT=sshd.service + _COMM=sshd <\/code>- Actions\n|- Currently banned: 12\n|- Total banned: 12\n`- Banned IP list: 112.85.42.194 40.124.5.76 46.101.164.33 117.50.36.137 221.181.185.19 119.28.178.61 222.187.232.73 221.131.165.124 218.92.0.223 221.181.185.200 221.181.185.199 190.171.133.10<\/pre>\n\n\n\n<p>\u4eca\u5929\u65f6\u95f4\u6bd4\u8f83\u7d27\uff0c\u5f53\u521d\u4e5f\u6ca1\u6709\u60f3\u5230\u88ab\u7ecf\u5e38SSH\u66b4\u529b\u7834\u89e3\u653b\u51fb\u7684\u95ee\u9898\uff0c\u4ece\u6839\u6e90\u4e0a\u8fd8\u662f\u5e94\u8be5\u66f4\u6362ssh\u7aef\u53e3\uff0c\u5173\u95ed\u8d26\u53f7\u5bc6\u7801\u767b\u5f55\u7b49\u6765\u5b9e\u73b0\u66f4\u5b89\u5168\u7684ssh\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u53c2\u8003<\/h2>\n\n\n\n<ol class=\"wp-block-list\"><li><a rel=\"noreferrer noopener\" href=\"https:\/\/blog.51cto.com\/winhe\/2114533\" data-type=\"URL\" data-id=\"https:\/\/blog.51cto.com\/winhe\/2114533\" target=\"_blank\">Linux\u5165*\u4fb5\u5206\u6790\uff08\u4e8c\uff09\u5206\u6790SSH\u767b\u5f55\u65e5\u5fd7<\/a><\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/blog.licess.com\/linux-vps-deny-ip\/\" target=\"_blank\">Linux VPS\u7981\u6b62\u67d0\u4e2aIP\u8bbf\u95ee<\/a><\/li><li><a href=\"http:\/\/haoqi.org\/13662.html\">CentOS\u5b89\u88c5Fail2ban\u4e4b\u5c0f\u767d\u653b\u7565<\/a><\/li><li><a rel=\"noreferrer noopener\" href=\"https:\/\/www.yuque.com\/wangdd\/blog\/ih9pz2\" target=\"_blank\">\u81ea\u52a8IP\u62e6\u622a\u5de5\u5177fail2ban\u4f7f\u7528\u6559\u7a0b<\/a><\/li><\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u4e0b\u5348\uff0c\u6253\u5f00\u535a\u5ba2\u7684\u65f6\u5019\u5f88\u5361\uff0c\u9875\u9762\u63d0\u793a\u6570\u636e\u5e93\u9519\u8bef\u6216\u8005\u670d\u52a1\u5668\u8d1f\u8f7d\u8fc7\u9ad8\u3002 \u6253\u5f00VPS\u540e\u53f0\uff0c\u53d1\u73b0CPU\u548c\u78c1\u76d8\u8d1f\u8f7d\u5f88\u9ad8 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[254,255],"class_list":["post-989","post","type-post","status-publish","format-standard","hentry","category-vpslog","tag-fail2ban","tag-ssh"],"_links":{"self":[{"href":"https:\/\/blog.francis67.cc\/index.php?rest_route=\/wp\/v2\/posts\/989","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.francis67.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.francis67.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.francis67.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.francis67.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=989"}],"version-history":[{"count":3,"href":"https:\/\/blog.francis67.cc\/index.php?rest_route=\/wp\/v2\/posts\/989\/revisions"}],"predecessor-version":[{"id":994,"href":"https:\/\/blog.francis67.cc\/index.php?rest_route=\/wp\/v2\/posts\/989\/revisions\/994"}],"wp:attachment":[{"href":"https:\/\/blog.francis67.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=989"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.francis67.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=989"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.francis67.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=989"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}