﻿{"id":6276,"date":"2021-02-26T20:38:14","date_gmt":"2021-02-26T12:38:14","guid":{"rendered":"https:\/\/www.linuxmi.com\/?p=6276"},"modified":"2021-02-26T20:38:14","modified_gmt":"2021-02-26T12:38:14","slug":"ubuntu-linux-2-factor-authentication","status":"publish","type":"post","link":"https:\/\/www.linuxmi.com\/ubuntu-linux-2-factor-authentication.html","title":{"rendered":"Ubuntu Linux\u4e0a\u542f\u7528\u591a\u91cd\u8eab\u4efd\u9a8c\u8bc1\uff0c\u8ba9\u7cfb\u7edf\u66f4\u5b89\u5168"},"content":{"rendered":"<p>\u968f\u7740\u65f6\u4ee3\u7684\u53d1\u5c55\uff0c\u4f20\u7edf\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u9a8c\u8bc1\u5df2\u88ab\u8bc1\u660e\u4e0d\u80fd\u4e3a\u5e94\u7528\u7a0b\u5e8f\u548c\u7cfb\u7edf\u63d0\u4f9b\u5f3a\u5927\u7684\u5b89\u5168\u6027\u3002\u7b80\u5355\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u53ef\u4ee5\u88ab\u591a\u79cd\u9ed1\u5ba2\u5de5\u5177\u8f7b\u677e\u7834\u89e3\uff0c\u4ece\u800c\u4f7f\u7cfb\u7edf\u5bb9\u6613\u53d7\u5230\u7834\u574f\u3002\u56e0\u6b64\uff0c\u4efb\u4f55\u8ba4\u771f\u5bf9\u5f85\u5b89\u5168\u6027\u7684\u516c\u53f8\u6216\u5b9e\u4f53\u90fd\u9700\u8981\u5b9e\u65bd<strong>2-Factor authentication\uff0c<\/strong>\u5b57\u9762\u610f\u601d\u53cc\u56e0\u7d20\u8ba4\u8bc1\uff0c\u4e5f\u79f0\u4e3a\u53cc\u91cd\u8ba4\u8bc1\u3002<\/p>\n<p>\u901a\u5e38\u79f0\u4e3a\u00a0<strong>MFA<\/strong>\u00a0(<strong>Multi-Factor Authentication<\/strong>)(\u591a\u56e0\u7d20\u8eab\u4efd\u9a8c\u8bc1)\uff0c\u53cc\u56e0\u7d20\u8eab\u4efd\u9a8c\u8bc1\u63d0\u4f9b\u4e86\u989d\u5916\u7684\u5b89\u5168\u5c42\uff0c\u8981\u6c42\u7528\u6237\u5728\u4f7f\u7528\u901a\u5e38\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\u4e4b\u524d\u6216\u4e4b\u540e\u63d0\u4f9b\u67d0\u4e9b\u7ec6\u8282\uff0c\u5982\u4ee3\u7801\u6216OTP(\u4e00\u6b21\u6027\u5bc6\u7801)\u3002<\/p>\n<p>\u5982\u4eca\uff0c\u591a\u5bb6\u516c\u53f8\uff08\u4f8b\u5982Google\uff0cFacebook\uff0cTwitter\u548cAWS\uff09\u4e3a\u7528\u6237\u63d0\u4f9b\u4e86\u9009\u62e9\u8bbe\u7f6eMFA\u6765\u8fdb\u4e00\u6b65\u4fdd\u62a4\u5176\u5e10\u6237\u7684\u9009\u62e9\u3002<\/p>\n<p><strong>\u5728\u672c\u6307\u5357\u4e2d\uff0c\u6211\u4eec\u6f14\u793a\u4e86\u5982\u4f55\u5728Ubuntu\u4e0a\u4f7f\u7528\u53cc\u91cd\u8eab\u4efd\u9a8c\u8bc1\u3002<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6291\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2021\/02\/ubuntu-20.04.2-2021-02-26-14-20-26.png\" alt=\"\" width=\"1920\" height=\"1200\" \/><\/p>\n<p><strong>\u7b2c1\u6b65\uff1a\u5b89\u88c5Google\u7684PAM\u8f6f\u4ef6\u5305<\/strong><\/p>\n<p>\u9996\u5148\uff0c\u5b89\u88c5Google PAM\u8f6f\u4ef6\u5305\u3002 PAM\u662f\u53ef\u63d2\u5165\u8eab\u4efd\u9a8c\u8bc1\u6a21\u5757\u7684\u7f29\u5199\uff0c\u662f\u4e00\u79cd\u5728Linux\u5e73\u53f0\u4e0a\u63d0\u4f9b\u989d\u5916\u8eab\u4efd\u9a8c\u8bc1\u5c42\u7684\u673a\u5236\u3002<\/p>\n<p>\u8be5\u8f6f\u4ef6\u5305\u6258\u7ba1\u5728Ubuntu\u5b58\u50a8\u5e93\u4e2d\uff0c\u56e0\u6b64\u8bf7\u7ee7\u7eed\u5e76\u4f7f\u7528apt\u547d\u4ee4\u6309\u5982\u4e0b\u6240\u793a\u5b89\u88c5\u5b83\uff1a<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">sudo apt install libpam-google-authenticator<\/span><\/p>\n<p>\u51fa\u73b0\u63d0\u793a\u65f6\uff0c\u6309\u201c Y\u201d\uff0c\u7136\u540e\u6309Enter\u4ee5\u7ee7\u7eed\u5b89\u88c5\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-6279 size-full\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2021\/02\/2021-02-26-13-53-44\u5c4f\u5e55\u622a\u56fe.png\" alt=\"\" width=\"786\" height=\"461\" \/><\/p>\n<p><strong>\u7b2c2\u6b65\uff1a\u5728\u667a\u80fd\u624b\u673a\u4e0a\u5b89\u88c5Google \u8eab\u4efd\u9a8c\u8bc1\u5668<\/strong><\/p>\n<p>\u6b64\u5916\uff0c\u60a8\u9700\u8981\u5728\u5e73\u677f\u7535\u8111\u6216\u667a\u80fd\u624b\u673a\u4e0a\u5b89\u88c5Google \u8eab\u4efd\u9a8c\u8bc1\u5668\u3002 \u8be5\u5e94\u7528\u5c06\u4e3a\u60a8\u63d0\u4f9b6\u4f4d\u6570\u7684OTP\u4ee3\u7801\uff0c\u8be5\u4ee3\u7801\u6bcf30\u79d2\u81ea\u52a8\u66f4\u65b0\u4e00\u6b21\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6280\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2021\/02\/IMG_3420.png\" alt=\"\" width=\"1125\" height=\"799\" \/><\/p>\n<p><strong>\u7b2c3\u6b65\uff1a\u5728Ubuntu\u4e2d\u914d\u7f6eGoogle PAM<\/strong><\/p>\n<p>\u5b89\u88c5\u8bbe\u7f6e\u597dGoogle \u8eab\u4efd\u9a8c\u8bc1\u5668\u540e\uff0c\u6211\u4eec\u5c06\u901a\u8fc7\u4fee\u6539\/etc\/pam.d\/common-auth\u6587\u4ef6\uff0c\u5728Ubuntu\u4e0a\u7ee7\u7eed\u8fdb\u884c\u914d\u7f6e\uff0c\u5e76\u914d\u7f6eGoogle PAM\u8f6f\u4ef6\u5305\uff0c\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">sudo vim \/etc\/pam.d\/common-auth<\/span><\/p>\n<p>\u5c06\u4e0b\u9762\u8fd9\u884c\u4ee3\u7801\u8ffd\u52a0\u5230\u6587\u4ef6\u4e2d\u3002<\/p>\n<p>auth required pam_google_authenticator.so<\/p>\n<p>\u4fdd\u5b58\u6587\u4ef6\u5e76\u9000\u51fa\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6281\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2021\/02\/2021-02-26-14-16-24\u5c4f\u5e55\u622a\u56fe.png\" alt=\"\" width=\"786\" height=\"569\" \/><\/p>\n<p>\u73b0\u5728\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u521d\u59cb\u5316PAM\u3002<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">google-authenticator<\/span><\/p>\n<p>\u7136\u540e\u4f1a\u5728\u60a8\u7684\u7ec8\u7aef\u5c4f\u5e55\u4e0a\u51fa\u73b0\u51e0\u4e2a\u95ee\u9898\u3002 \u9996\u5148\uff0c\u5c06\u8be2\u95ee\u60a8\u662f\u5426\u8981\u4f7f\u8eab\u4efd\u9a8c\u8bc1\u4ee4\u724c\u57fa\u4e8e\u65f6\u95f4\uff08<strong>Time-based<\/strong>\uff09\u3002<\/p>\n<p>\u57fa\u4e8e\u65f6\u95f4\u7684\u8eab\u4efd\u9a8c\u8bc1\u4ee4\u724c\u4f1a\u5728\u7279\u5b9a\u65f6\u95f4\u540e\u8fc7\u671f\u3002 \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u8fd9\u662f\u572830\u79d2\u4e4b\u540e\uff0c\u4e4b\u540e\u4f1a\u751f\u6210\u4e00\u7ec4\u65b0\u7684\u4ee4\u724c\u3002 \u8fd9\u4e9b\u4ee4\u724c\u88ab\u8ba4\u4e3a\u6bd4\u975e\u57fa\u4e8e\u65f6\u95f4\u7684\u4ee4\u724c\u66f4\u5b89\u5168\uff0c\u56e0\u6b64\uff0c\u5c06\u952e\u5165\u201c y\u201d\u8868\u793a\u201cYes\u201d\uff0c\u7136\u540e\u6309Enter\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u4e8c\u7ef4\u7801\u5c06\u663e\u793a\u5728\u7ec8\u7aef\u4e0a\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u5e76\u5728\u5176\u53f3\u4e0b\u65b9\uff0c\u5c06\u663e\u793a\u4e00\u4e9b\u4fe1\u606f\u3002 \u663e\u793a\u7684\u4fe1\u606f\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>Secret key\u00a0 \u5bc6\u94a5<\/li>\n<li>Verification code\u00a0 \u9a8c\u8bc1\u7801<\/li>\n<li>Emergency scratch codes\u00a0 \u5e94\u6025\u5907\u7528\u9a8c\u8bc1\u7801\uff0c\u624b\u673a\u4e0d\u5728\u8eab\u8fb9\u53ef\u4ee5\u4f7f\u7528\uff0c\u4e0d\u8fc7\u4e00\u4e2a\u7801\u53ea\u80fd\u7528\u4e00\u6b21<\/li>\n<\/ul>\n<p>\u60a8\u9700\u8981\u5c06\u6b64\u4fe1\u606f\u4fdd\u5b58\u5230Vault\u4e2d\uff0c\u4ee5\u5907\u5c06\u6765\u53c2\u8003\u3002 \u5982\u679c\u60a8\u4e22\u5931\u4e86\u8eab\u4efd\u9a8c\u8bc1\u5668\u8bbe\u5907\uff0c\u5219\u5e94\u6025\u5907\u7528\u9a8c\u8bc1\u7801\u975e\u5e38\u6709\u7528\u3002 \u5982\u679c\u60a8\u7684\u8eab\u4efd\u9a8c\u8bc1\u8bbe\u5907\u53d1\u751f\u610f\u5916\u4e8b\u60c5\uff0c\u8bf7\u4f7f\u7528\u4ee3\u7801\u3002<\/p>\n<p>\u5728\u60a8\u7684\u667a\u80fd\u8bbe\u5907\u4e0a\u542f\u52a8Google \u8eab\u4efd\u9a8c\u8bc1\u5668\uff0c\u7136\u540e\u9009\u62e9\u201c\u626b\u63cf\u4e8c\u7ef4\u7801\u201d\u4ee5\u626b\u63cf\u663e\u793a\u7684\u4e8c\u7ef4\u7801\u3002<\/p>\n<p>\u6ce8\u610f\uff1a\u60a8\u9700\u8981\u6700\u5927\u5316\u7ec8\u7aef\u7a97\u53e3\u624d\u80fd\u626b\u63cf\u6574\u4e2a\u4e8c\u7ef4\u7801\u3002 \u626b\u63cf\u4e8c\u7ef4\u7801\u540e\uff0c\u6bcf30\u79d2\u66f4\u6539\u4e00\u6b21\u7684\u516d\u4f4dOTP\u5c06\u663e\u793a\u5728\u5e94\u7528\u7a0b\u5e8f\u4e0a\u3002<\/p>\n<p>\u4e4b\u540e\uff0c\u9009\u62e9\u201c y\u201d\u4ee5\u66f4\u65b0\u60a8\u7684\u4e3b\u6587\u4ef6\u5939\u4e2d\u7684Google\u8eab\u4efd\u9a8c\u8bc1\u5668\u6587\u4ef6\u3002<\/p>\n<p>\u5728\u4e0b\u4e00\u4e2a\u63d0\u793a\u4e2d\uff0c\u5c06\u767b\u5f55\u9650\u5236\u4e3a\u6bcf30\u79d2\u4ec5\u767b\u5f55\u4e00\u6b21\uff0c\u4ee5\u9632\u6b62\u53ef\u80fd\u7531\u4e8e\u4e2d\u95f4\u4eba\u653b\u51fb\u800c\u5f15\u8d77\u7684\u653b\u51fb\u3002 \u56e0\u6b64\u9009\u62e9\u201c y\u201d<\/p>\n<p>\u5728\u4e0b\u4e00\u4e2a\u63d0\u793a\u4e2d\uff0c\u9009\u62e9\u201c n\u201d\u4ee5\u7981\u6b62\u5ef6\u957f\u6301\u7eed\u65f6\u95f4\uff0c\u8be5\u6301\u7eed\u65f6\u95f4\u89e3\u51b3\u4e86\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u4e4b\u95f4\u7684\u65f6\u95f4\u504f\u5dee\u3002 \u9664\u975e\u60a8\u9047\u5230\u65f6\u95f4\u540c\u6b65\u5dee\u7684\u6311\u6218\uff0c\u5426\u5219\u8fd9\u662f\u66f4\u5b89\u5168\u7684\u9009\u62e9\u3002<\/p>\n<p>\u6700\u540e\uff0c\u4ec5\u5bf93\u6b21\u767b\u5f55\u5c1d\u8bd5\u542f\u7528\u901f\u7387\u9650\u5236\u3002<\/p>\n<p>\u5982\u56fe\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6282\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2021\/02\/2021-02-26-14-24-50\u5c4f\u5e55\u622a\u56fe.png\" alt=\"\" width=\"786\" height=\"785\" \/><\/p>\n<p>\u81f3\u6b64\uff0c\u6211\u4eec\u5df2\u7ecf\u5b8c\u6210\u4e86\u53cc\u56e0\u7d20\u8eab\u4efd\u9a8c\u8bc1\u529f\u80fd\u7684\u5b9e\u73b0\u3002 \u5b9e\u9645\u4e0a\uff0c\u5982\u679c\u60a8\u8fd0\u884c\u4efb\u4f55sudo\u547d\u4ee4\uff0c\u7cfb\u7edf\u5c06\u63d0\u793a\u60a8\u8f93\u5165\u9a8c\u8bc1\u7801\uff0c\u60a8\u53ef\u4ee5\u4eceGoogle \u8eab\u4efd\u9a8c\u8bc1\u5668\u5e94\u7528\u4e2d\u83b7\u53d6\u8be5\u9a8c\u8bc1\u7801\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6283\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2021\/02\/2021-02-26-14-29-26\u5c4f\u5e55\u622a\u56fe.png\" alt=\"\" width=\"786\" height=\"389\" \/><\/p>\n<p>\u60a8\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u542f\u52a8\u6765\u8fdb\u4e00\u6b65\u9a8c\u8bc1\u8fd9\u4e00\u70b9\uff0c\u4e00\u65e6\u8fdb\u5165\u767b\u5f55\u5c4f\u5e55\uff0c\u7cfb\u7edf\u5c06\u8981\u6c42\u60a8\u63d0\u4f9b\u9a8c\u8bc1\u7801\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6284\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2021\/02\/ubuntu-20.04.2-2021-02-26.png\" alt=\"\" width=\"572\" height=\"439\" \/><\/p>\n<p>\u5728\u4f60\u4eceGoogle\u8eab\u4efd\u8bc1\u9a8c\u8bc1\u5668\u63d0\u4f9b\u4e86\u4f60\u7684\u4ee3\u7801\u540e\uff0c\u8fd8\u9700\u8981\u63d0\u4f9b\u4f60\u7684\u5bc6\u7801\u624d\u53ef\u4ee5\u8bbf\u95ee\u4f60\u7684\u7cfb\u7edf\u3002<\/p>\n<p><strong>\u7b2c4\u6b65\uff1a\u5c06SSH\u4e0eGoogle\u8eab\u4efd\u9a8c\u8bc1\u5668\u96c6\u6210<\/strong><\/p>\n<p>\u5982\u679c\u60a8\u6253\u7b97\u5c06SSH\u4e0e\u8c37\u6b4cPAM\u6a21\u5757\u4e00\u8d77\u4f7f\u7528\uff0c\u5219\u9700\u8981\u5c06\u4e24\u8005\u96c6\u6210\u8d77\u6765\u3002\u6709\u4e24\u79cd\u65b9\u6cd5\u53ef\u4ee5\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6288\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2021\/02\/2021-02-26-15-55-58\u5c4f\u5e55\u622a\u56fe.png\" alt=\"\" width=\"784\" height=\"551\" \/><\/p>\n<p><strong>SSH\u5bc6\u7801\u8ba4\u8bc1<\/strong><\/p>\n<p>\u5982\u679c\u9700\u8981\u5bf9\u666e\u901a\u7528\u6237\u8fdb\u884cSSH\u5bc6\u7801\u8ba4\u8bc1\uff0c\u9996\u5148\u9700\u8981\u6253\u5f00SSH\u9ed8\u8ba4\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">sudo vim \/etc\/ssh\/sshd_config<\/span><\/p>\n<p>\u5e76\u5c06\u4ee5\u4e0b\u5c5e\u6027\u8bbe\u7f6e\u4e3a\u201cyes\u201d\uff0c\u5982\u4e0b\u6240\u793a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6285\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2021\/02\/2021-02-26-15-41-53\u5c4f\u5e55\u622a\u56fe.png\" alt=\"\" width=\"786\" height=\"533\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-6286 size-full\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2021\/02\/2021-02-26-15-42-04\u5c4f\u5e55\u622a\u56fe.png\" alt=\"\" width=\"786\" height=\"533\" \/><\/p>\n<p>\u5bf9\u4e8eroot\u7528\u6237\uff0c\u5c06\u201cPermitRootLogin\u201d\u5c5e\u6027\u8bbe\u7f6e\u4e3a\u201cyes\u201d\u3002<\/p>\n<p>PermitRootLogin yes<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-6287 size-full\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2021\/02\/2021-02-26-15-43-00\u5c4f\u5e55\u622a\u56fe.png\" alt=\"\" width=\"786\" height=\"533\" \/><\/p>\n<p>\u4fdd\u5b58\u6587\u4ef6\u5e76\u9000\u51fa\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u4fee\u6539SSH\u7684PAM\u89c4\u5219<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">sudo vim \/etc\/pam.d\/sshd<\/span><\/p>\n<p>\u7136\u540e\u8ffd\u52a0\u4ee5\u4e0b\u884c<\/p>\n<p>auth required pam_google_authenticator.so<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6289\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2021\/02\/2021-02-26-15-45-12\u5c4f\u5e55\u622a\u56fe.png\" alt=\"\" width=\"786\" height=\"533\" \/><\/p>\n<p>\u6700\u540e\uff0c\u91cd\u65b0\u542f\u52a8SSH\u670d\u52a1\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\u3002<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">sudo systemctl restart ssh<\/span><\/p>\n<p>\u5728\u4e0b\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4ecePutty\u5ba2\u6237\u7aef\u767b\u5f55\u5230Ubuntu\u7cfb\u7edf\u3002<\/p>\n<p><strong>\u5bf9\u4e8eSSH\u516c\u94a5\u8eab\u4efd\u9a8c\u8bc1<\/strong><\/p>\n<p>\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f\u516c\u94a5\u8eab\u4efd\u9a8c\u8bc1\uff0c\u8bf7\u91cd\u590d\u4e0a\u8ff0\u6b65\u9aa4\u5e76\u6dfb\u52a0\/etc\/ssh\/sshd_config\u6587\u4ef6\u5e95\u90e8\u663e\u793a\u7684\u884c\u3002<\/p>\n<p>AuthenticationMethods publickey,keyboard-interactive<\/p>\n<p>\u518d\u6b21\u7f16\u8f91SSH\u5b88\u62a4\u7a0b\u5e8f\u7684PAM\u89c4\u5219\u3002<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$<span style=\"color: #ff0000;\"> sudo vim \/etc\/pam.d\/sshd<\/span><\/p>\n<p>\u7136\u540e\u6dfb\u52a0\u4ee5\u4e0b\u884c\u3002<\/p>\n<p>auth required pam_google_authenticator.so<\/p>\n<p>\u4fdd\u5b58\u6587\u4ef6\u5e76\u91cd\u65b0\u542f\u52a8SSH\u670d\u52a1\uff0c\u5982\u6211\u4eec\u5148\u524d\u6240\u89c1\u7684\u56fe\u4f8b\u3002<\/p>\n<p>linuxmi@linuxmi:~\/www.linuxmi.com$ <span style=\"color: #ff0000;\">sudo systemctl restart ssh<\/span><\/p>\n<p><span style=\"color: #ff0000;\"><strong>OK\uff0c\u672c\u6587\u5230\u6b64\u7ed3\u675f\uff0c\u53ea\u505a\u6d4b\u8bd5\u7814\u7a76\u4e4b\u7528\uff0c\u5982\u6709\u95ee\u9898\u4e0d\u8981\u627e\u6211\u54e6\u3002<\/strong><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u968f\u7740\u65f6\u4ee3\u7684\u53d1\u5c55\uff0c\u4f20\u7edf\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u9a8c\u8bc1\u5df2\u88ab\u8bc1\u660e\u4e0d\u80fd\u4e3a\u5e94\u7528\u7a0b\u5e8f\u548c\u7cfb\u7edf\u63d0\u4f9b\u5f3a\u5927\u7684\u5b89\u5168\u6027\u3002\u7b80\u5355\u7684\u7528\u6237\u540d\u548c\u5bc6 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-6276","post","type-post","status-publish","format-standard","hentry","category-linux"],"aioseo_notices":[],"views":1222,"_links":{"self":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/6276","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/comments?post=6276"}],"version-history":[{"count":4,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/6276\/revisions"}],"predecessor-version":[{"id":6292,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/6276\/revisions\/6292"}],"wp:attachment":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/media?parent=6276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/categories?post=6276"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/tags?post=6276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}