{"id":802,"date":"2017-05-19T17:10:08","date_gmt":"2017-05-19T09:10:08","guid":{"rendered":"http:\/\/www.sulabs.net\/?p=802"},"modified":"2020-08-28T18:25:26","modified_gmt":"2020-08-28T10:25:26","slug":"802","status":"publish","type":"post","link":"https:\/\/www.sulabs.net\/?p=802","title":{"rendered":"CentOS \u4f7f\u7528\u8c37\u6b4c\u8eab\u4efd\u9a8c\u8bc1\u5668\u505aSSH\u4e8c\u6b21\u8ba4\u8bc1"},"content":{"rendered":"<p>\u6587\u7ae0\u8f6c\u81eahttp:\/\/www.he11oworld.com\/system\/2883.html<br \/>\n\u5411\u539f\u4f5c\u8005\u6807\u8bc6\u611f\u8c22<br \/>\n\u672c\u6587\u90e8\u5206\u5185\u5bb9\u6709\u6240\u53d8\u66f4\u8fdb\u884c\u4e86\u4fee\u6b63\u5904\u7406\u3002<\/p>\n<p>\u8c37\u6b4c\u8eab\u4efd\u9a8c\u8bc1\u5668\u751f\u6210\u7684\u662f\u52a8\u6001\u9a8c\u8bc1\u7801\uff0c\u9ed8\u8ba430\u79d2\u66f4\u65b0\u3002\u4fee\u6539\u914d\u7f6e\uff0cSSH\u767b\u5f55\u5fc5\u987b\u5728\u8f93\u5165\u5bc6\u7801\u4e4b\u524d\u8f93\u5165\u52a8\u6001\u9a8c\u8bc1\u7801\u3002\u5373\u4f7f\u8d26\u53f7\u548c\u5bc6\u7801\u6cc4\u9732\uff0c\u9a8c\u8bc1\u7801\u8f93\u5165\u9519\u8bef\uff0c\u4ecd\u7136\u65e0\u6cd5\u767b\u5f55\u3002\u82f9\u679c\u6216\u8005\u5b89\u5353\u624b\u673a\u7aef\u53ef\u4ee5\u5b89\u88c5\u8eab\u4efd\u9a8c\u8bc1\u5668App\u8bfb\u53d6\u9a8c\u8bc1\u7801\u3002\u8c37\u6b4c\u8eab\u4efd\u8ba4\u8bc1\u5668\u4e5f\u6709\u5176\u5b83PHP,JAVA\u7b49\u8bed\u8a00\u7248\u672c\uff0c\u7528\u9014\u5e7f\u6cdb\u3002<br \/>\n<!--more--><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-803\" title=\"CentOS\u670d\u52a1\u5668\u4f7f\u7528Google\u4e8c\u6b21\u9a8c\u8bc1\u767b\u9646 \u7b2c1\u5f20\" src=\"https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7da0001b1f363219de0.jpg\" alt=\"CentOS\u670d\u52a1\u5668\u4f7f\u7528Google\u4e8c\u6b21\u9a8c\u8bc1\u767b\u9646 \u7b2c1\u5f20\" width=\"640\" height=\"481\" srcset=\"https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7da0001b1f363219de0.jpg 640w, https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7da0001b1f363219de0-300x225.jpg 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p><strong>1.\u5b89\u88c5\u524d\u51c6\u5907<br \/>\n<\/strong>1). Git \u5730\u5740\uff1ahttps:\/\/github.com\/google\/google-authenticator-libpam.git<br \/>\n2). \u5b89\u88c5\u4f9d\u8d56\uff1ayum -y install gcc make pam-devel libpng-devel libtool wget git<br \/>\n3). \u5f00\u542fEPEL\u6e90 yum --enablerepo=epel<br \/>\n\u6216\u8005\u76f4\u63a5\u5b89\u88c5EPEL\u6e90RPM\u5305<br \/>\n# CentOS 6<br \/>\nrpm -Uvh http:\/\/mirrors.ustc.edu.cn\/fedora\/epel\/epel-release-latest-6.noarch.rpm&nbsp;<br \/>\n# CentOS 7<br \/>\nrpm -Uvh http:\/\/mirrors.ustc.edu.cn\/fedora\/epel\/epel-release-latest-7.noarch.rpm<\/p>\n<p>4).\u5b89\u88c5Qrencode\uff0c\u8c37\u6b4c\u8eab\u4efd\u9a8c\u8bc1\u5668\u9700\u8981\u8c03\u7528\u8be5\u7a0b\u5e8f\u751f\u6210\u4e8c\u7ef4\u7801\u5e76\u663e\u793a<br \/>\nyum install -y qrencode<\/p>\n<p><strong>2.\u5b89\u88c5\u8c37\u6b4c\u8eab\u4efd\u9a8c\u8bc1\u5668<br \/>\n<\/strong>git clone&nbsp;https:\/\/github.com\/google\/google-authenticator-libpam.git<br \/>\ncd google-authenticator-libpam\/<\/p>\n<p>\u7f16\u8bd1\u5e76\u5b89\u88c5<br \/>\n.\/bootstrap.sh<br \/>\n.\/configure --prefix=\/usr\/local\/google-authenticator<br \/>\nmake &amp;&amp; make install<\/p>\n<p>\u590d\u5236google \u8eab\u4efd\u9a8c\u8bc1\u5668pam\u6a21\u5757\u5230\u7cfb\u7edf\u4e0b<br \/>\ncp \/usr\/local\/google\/authenticator\/lib\/security\/pam_google_authenticator.so \/lib64\/security\/<\/p>\n<p><strong>3.\u914d\u7f6e\/etc\/pam.d\/sshd<\/strong><\/p>\n<p>\u6dfb\u52a0\u56fe\u4e2d\u7ea2\u8272\u6846\u5185\u7684\u4e00\u884c\u5185\u5bb9<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-805\" title=\"CentOS\u670d\u52a1\u5668\u4f7f\u7528Google\u4e8c\u6b21\u9a8c\u8bc1\u767b\u9646 \u7b2c3\u5f20\" src=\"https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7da0001a49c212ec0ea.jpg\" alt=\"CentOS\u670d\u52a1\u5668\u4f7f\u7528Google\u4e8c\u6b21\u9a8c\u8bc1\u767b\u9646 \u7b2c3\u5f20\" width=\"640\" height=\"309\" srcset=\"https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7da0001a49c212ec0ea.jpg 640w, https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7da0001a49c212ec0ea-300x145.jpg 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p><strong>4.\u4fee\u6539SSH\u670d\u52a1\u914d\u7f6e\/etc\/ssh\/sshd_config<\/strong><br \/>\nChallengeResponseAuthentication yes<br \/>\n\u6216\u8005\u7528sed\u4fee\u6539<br \/>\nsed -i 's#^ChallengeResponseAuthentication no#ChallengeResponseAuthentication yes#' \/etc\/ssh\/sshd_config<\/p>\n<p><strong>5.\u91cd\u542fSSH\u670d\u52a1<br \/>\n<\/strong><\/p>\n<p>a)RHEL 6 \/ Centos6<br \/>\nservice sshd restart<\/p>\n<p>b)RHEL7 \/Centos 7<br \/>\nsystemctl resart sshd<\/p>\n<p><strong>6.\u5b89\u88c5\u5b8c\u6210\uff0c\u5f00\u59cb\u9a8c\u8bc1\u3002<\/strong><\/p>\n<p>a)\u5207\u6362\u5230\u9700\u8981\u9a8c\u8bc1\u7684\u7cfb\u7edf\u8d26\u6237\uff0c\u672c\u6848\u4f8b\u4f7f\u7528root\u7528\u6237\u3002<br \/>\nb)\u8fd0\u884c\u7a0b\u5e8f<br \/>\n.\/google-authenticator<br \/>\nDo you want authentication tokens to be time-based (y\/n) y<br \/>\n# \u662f\u5426\u5f00\u542f\u57fa\u4e8e\u65f6\u95f4\u7684\u8ba4\u8bc1\uff0cY<br \/>\n# \u63a5\u4e0b\u6765\u4f1a\u751f\u6210\u4e8c\u7ef4\u7801\uff0c\u624b\u673a\u7aef\u626b\u63cf\u5373\u53ef\u6dfb\u52a0\u5b89\u5168\u5bc6\u94a5<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-806\" title=\"CentOS\u670d\u52a1\u5668\u4f7f\u7528Google\u4e8c\u6b21\u9a8c\u8bc1\u767b\u9646 \u7b2c4\u5f20\" src=\"https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7b6000687a419c751d6.jpg\" alt=\"CentOS\u670d\u52a1\u5668\u4f7f\u7528Google\u4e8c\u6b21\u9a8c\u8bc1\u767b\u9646 \u7b2c4\u5f20\" width=\"640\" height=\"676\" srcset=\"https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7b6000687a419c751d6.jpg 640w, https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7b6000687a419c751d6-284x300.jpg 284w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><br \/>\nYour new secret key is: JS57SLVUDEEA7SQ7LD6BEBWGAA<br \/>\n# \u6ce8\u610f\u8fd9\u4e2a\u5b89\u5168KEY\u9700\u8981\u5907\u4efd\uff0c\u5f53\u66f4\u6362\u624b\u673a\u6216\u5b89\u88c5APP\u9700\u8981\u6dfb\u52a0KEY\u7528\u4e8e\u751f\u6210\u9a8c\u8bc1\u7801<\/p>\n<p>Your verification code is 225960<br \/>\nYour emergency scratch codes are:<br \/>\n# \u6ce8\u610f\u540e\u5907\u9a8c\u8bc1\u7801\u4fdd\u5b58\u597d\uff0c\u7528\u4e8e\u7d27\u6025\u4f7f\u7528\uff0c\u6bcf\u4e2a\u9a8c\u8bc1\u7801\u4f7f\u7528\u4e00\u6b21\u540e\u4f5c\u5e9f<br \/>\n50434230<br \/>\n90718846<br \/>\n71391250<br \/>\n25890913<br \/>\n60265036<br \/>\n&nbsp;<br \/>\nDo you want me to update your \"\/root\/.google_authenticator\" file (y\/n) y<br \/>\n&nbsp;<br \/>\nDo you want to disallow multiple uses of the same authentication<br \/>\ntoken? This restricts you to one login about every 30s, but it increases<br \/>\nyour chances to notice or even prevent man-in-the-middle attacks (y\/n)<br \/>\n&nbsp;<br \/>\nDo you want to disallow multiple uses of the same authentication<br \/>\ntoken? This restricts you to one login about every 30s, but it increases<br \/>\nyour chances to notice or even prevent man-in-the-middle attacks (y\/n) y<br \/>\n&nbsp;<br \/>\nBy default, tokens are good for 30 seconds. In order to compensate for<br \/>\npossible time-skew between the client and the server, we allow an extra<br \/>\ntoken before and after the current time. If you experience problems with<br \/>\npoor time synchronization, you can increase the window from its default<br \/>\nsize of +-1min (window size of 3) to about +-4min (window size of<br \/>\n17 acceptable tokens).<br \/>\nDo you want to do so? (y\/n) y<br \/>\n# \u5b89\u5168\u76f8\u5173\uff0c\u9ed8\u8ba4\u7ee7\u7eed<br \/>\n&nbsp;<br \/>\nIf the computer that you are logging into isn't hardened against brute-force<br \/>\nlogin attempts, you can enable rate-limiting for the authentication module.<br \/>\nBy default, this limits attackers to no more than 3 login attempts every 30s.<br \/>\nDo you want to enable rate-limiting (y\/n) y<br \/>\n# \u5b89\u5168\u76f8\u5173\uff0c\u9ed8\u8ba4\u7ee7\u7eed<\/p>\n<p><strong>7.\u7ec8\u7aef\u8bbe\u7f6egoogle \u4e8c\u6b21\u8eab\u4efd\u9a8c\u8bc1\u767b\u9646<\/strong><\/p>\n<p>\u6253\u5f00xshell(\u5176\u4ed6\u7ec8\u7aef\u7c7b\u4f3c)\uff0c\u9009\u62e9\u767b\u9646\u4e3b\u673a\u7684\u5c5e\u6027\u3002\u8bbe\u7f6e\u767b\u9646\u65b9\u6cd5\u4e3aKeyboard Interactive \u952e\u76d8\u4ea4\u4e92\u65b9\u5f0f<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-807\" title=\"CentOS\u670d\u52a1\u5668\u4f7f\u7528Google\u4e8c\u6b21\u9a8c\u8bc1\u767b\u9646 \u7b2c5\u5f20\" src=\"https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7b6000688bb2f74df4d.jpg\" alt=\"CentOS\u670d\u52a1\u5668\u4f7f\u7528Google\u4e8c\u6b21\u9a8c\u8bc1\u767b\u9646 \u7b2c5\u5f20\" width=\"640\" height=\"589\" srcset=\"https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7b6000688bb2f74df4d.jpg 640w, https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7b6000688bb2f74df4d-300x276.jpg 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>\u7528\u6237\u540d\uff1aroot\uff08\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u586b\u5199\uff09<br \/>\n\u5bc6\u7801\u4e3a\u7a7a\u5c31\u597d\uff08\u56e0\u4e3a\u9700\u8981\u5148\u4e8c\u6b21\u9a8c\u8bc1\uff0c\u518d\u586b\u5165\u5bc6\u7801\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-808\" title=\"CentOS\u670d\u52a1\u5668\u4f7f\u7528Google\u4e8c\u6b21\u9a8c\u8bc1\u767b\u9646 \u7b2c6\u5f20\" src=\"https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7da0001a6c3e0337038.jpg\" alt=\"CentOS\u670d\u52a1\u5668\u4f7f\u7528Google\u4e8c\u6b21\u9a8c\u8bc1\u767b\u9646 \u7b2c6\u5f20\" width=\"640\" height=\"585\" srcset=\"https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7da0001a6c3e0337038.jpg 640w, https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7da0001a6c3e0337038-300x274.jpg 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>\u4e8c\u6b21\u9a8c\u8bc1\u7801\u8f93\u5165<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-809\" title=\"CentOS\u670d\u52a1\u5668\u4f7f\u7528Google\u4e8c\u6b21\u9a8c\u8bc1\u767b\u9646 \u7b2c7\u5f20\" src=\"https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7b6000689307763bc20.jpg\" alt=\"CentOS\u670d\u52a1\u5668\u4f7f\u7528Google\u4e8c\u6b21\u9a8c\u8bc1\u767b\u9646 \u7b2c7\u5f20\" width=\"418\" height=\"235\" srcset=\"https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7b6000689307763bc20.jpg 418w, https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7b6000689307763bc20-300x169.jpg 300w\" sizes=\"auto, (max-width: 418px) 100vw, 418px\" \/><\/p>\n<p>\u7cfb\u7edf\u7528\u6237\u5bc6\u7801\u8f93\u5165<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-810\" title=\"CentOS\u670d\u52a1\u5668\u4f7f\u7528Google\u4e8c\u6b21\u9a8c\u8bc1\u767b\u9646 \u7b2c8\u5f20\" src=\"https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7b600068960e39637f7.jpg\" alt=\"CentOS\u670d\u52a1\u5668\u4f7f\u7528Google\u4e8c\u6b21\u9a8c\u8bc1\u767b\u9646 \u7b2c8\u5f20\" width=\"421\" height=\"236\" srcset=\"https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7b600068960e39637f7.jpg 421w, https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7b600068960e39637f7-300x168.jpg 300w\" sizes=\"auto, (max-width: 421px) 100vw, 421px\" \/><\/p>\n<p><strong>8.\u5b8c\u7f8e\u767b\u9646<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-811\" title=\"CentOS\u670d\u52a1\u5668\u4f7f\u7528Google\u4e8c\u6b21\u9a8c\u8bc1\u767b\u9646 \u7b2c9\u5f20\" src=\"https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7da0001a764590b70e7.jpg\" alt=\"CentOS\u670d\u52a1\u5668\u4f7f\u7528Google\u4e8c\u6b21\u9a8c\u8bc1\u767b\u9646 \u7b2c9\u5f20\" width=\"640\" height=\"360\" srcset=\"https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7da0001a764590b70e7.jpg 640w, https:\/\/www.sulabs.net\/wp-content\/uploads\/2017\/05\/Cfakepath7da0001a764590b70e7-300x169.jpg 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u8f6c\u81eahttp:\/\/www.he11oworld.com\/system\/288 &hellip;<\/p>\n<p class=\"read-more\"><a href=\"https:\/\/www.sulabs.net\/?p=802\">\u7ee7\u7eed\u9605\u8bfb &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":803,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[14,110,111],"class_list":["post-802","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-centos","tag-google","tag-111"],"_links":{"self":[{"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/posts\/802","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=802"}],"version-history":[{"count":5,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/posts\/802\/revisions"}],"predecessor-version":[{"id":960,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/posts\/802\/revisions\/960"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=\/wp\/v2\/media\/803"}],"wp:attachment":[{"href":"https:\/\/www.sulabs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sulabs.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}