{"id":17803,"date":"2024-11-18T16:55:02","date_gmt":"2024-11-18T08:55:02","guid":{"rendered":"https:\/\/fwq.ai\/blog\/17803\/"},"modified":"2024-11-18T16:55:02","modified_gmt":"2024-11-18T08:55:02","slug":"linux%e7%94%a8%e6%88%b7%e5%af%86%e7%a0%81%e5%ad%98%e6%94%be%e4%bd%8d%e7%bd%ae%e7%9a%84%e6%9c%80%e4%bd%b3%e5%ae%9e%e8%b7%b5%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/17803\/","title":{"rendered":"Linux\u7528\u6237\u5bc6\u7801\u5b58\u653e\u4f4d\u7f6e\u7684\u6700\u4f73\u5b9e\u8df5\u6307\u5357"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/887\/227\/171097938793225.jpg\" class=\"aligncenter\" title=\"Linux\u7528\u6237\u5bc6\u7801\u5b58\u653e\u4f4d\u7f6e\u7684\u6700\u4f73\u5b9e\u8df5\u6307\u5357\u63d2\u56fe\" alt=\"Linux\u7528\u6237\u5bc6\u7801\u5b58\u653e\u4f4d\u7f6e\u7684\u6700\u4f73\u5b9e\u8df5\u6307\u5357\u63d2\u56fe\" \/><\/p>\n<p><strong>Linux\u7528\u6237\u5bc6\u7801\u5b58\u653e\u4f4d\u7f6e\u7684\u6700\u4f73\u5b9e\u8df5\u6307\u5357<\/strong><\/p>\n<p>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u7528\u6237\u5bc6\u7801\u7684\u5b58\u653e\u662f\u4e00\u9879\u81f3\u5173\u91cd\u8981\u7684\u5b89\u5168\u63aa\u65bd\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u4e00\u4e9bLinux\u7cfb\u7edf\u4e2d\u7528\u6237\u5bc6\u7801\u5b58\u653e\u7684\u6700\u4f73\u5b9e\u8df5\uff0c\u4ee5\u786e\u4fdd\u5bc6\u7801\u7684\u5b89\u5168\u6027\uff0c\u5e76\u63d0\u4f9b\u5177\u4f53\u7684\u4ee3\u7801\u793a\u4f8b\u7528\u4e8e\u53c2\u8003\u3002<\/p>\n<p><strong>1. \u4f7f\u7528\u52a0\u5bc6\u7b97\u6cd5\u5b58\u50a8\u5bc6\u7801<\/strong><\/p>\n<p>Linux\u7cfb\u7edf\u901a\u5e38\u4f1a\u4f7f\u7528\u52a0\u5bc6\u7b97\u6cd5\u5bf9\u7528\u6237\u5bc6\u7801\u8fdb\u884c\u5b58\u50a8\uff0c\u4ee5\u786e\u4fdd\u5bc6\u7801\u5728\u5b58\u50a8\u548c\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u7684\u5b89\u5168\u6027\u3002\u5e38\u89c1\u7684\u52a0\u5bc6\u7b97\u6cd5\u5305\u62ecMD5\u3001SHA-256\u7b49\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u4f7f\u7528SHA-256\u7b97\u6cd5\u5bf9\u7528\u6237\u5bc6\u7801\u8fdb\u884c\u52a0\u5bc6\uff1a<\/p>\n<pre>$ echo -n 'mysecurepassword' | sha256sum<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>2. \u4f7f\u7528salt\u589e\u52a0\u5bc6\u7801\u7684\u5b89\u5168\u6027<\/strong><\/p>\n<p>\u4e3a\u4e86\u589e\u52a0\u5bc6\u7801\u7684\u5b89\u5168\u6027\uff0c\u53ef\u4ee5\u4f7f\u7528\u968f\u673a\u751f\u6210\u7684salt\u503c\u8fdb\u884c\u5bc6\u7801\u52a0\u5bc6\u3002salt\u662f\u4e00\u4e2a\u968f\u673a\u751f\u6210\u7684\u5b57\u7b26\u4e32\uff0c\u88ab\u6dfb\u52a0\u5230\u5bc6\u7801\u4e2d\uff0c\u53ef\u4ee5\u9632\u6b62\u76f8\u540c\u7684\u5bc6\u7801\u5bf9\u5e94\u76f8\u540c\u7684\u52a0\u5bc6\u7ed3\u679c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u4f7f\u7528salt\u503c\u5bf9\u5bc6\u7801\u8fdb\u884c\u52a0\u5bc6\uff1a<\/p>\n<pre>$ password='mysecurepassword'\n$ salt=$(openssl rand -base64 12)\n$ echo -n \"$password$salt\" | sha256sum<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>3. \u4f7f\u7528\u6563\u5217\u548c\u8fed\u4ee3\u6b21\u6570\u52a0\u5f3a\u5bc6\u7801\u7684\u5b89\u5168\u6027<\/strong><\/p>\n<p>\u4e3a\u4e86\u589e\u5f3a\u5bc6\u7801\u7684\u5b89\u5168\u6027\uff0c\u53ef\u4ee5\u901a\u8fc7\u591a\u6b21\u8fed\u4ee3\u5bf9\u5bc6\u7801\u8fdb\u884c\u52a0\u5bc6\u3002\u8fd9\u6837\u53ef\u4ee5\u589e\u52a0\u7834\u89e3\u5bc6\u7801\u7684\u96be\u5ea6\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u5bf9\u5bc6\u7801\u8fdb\u884c\u591a\u6b21\u8fed\u4ee3\u52a0\u5bc6\uff1a<\/p>\n<pre>$ password='mysecurepassword'\n$ salt=$(openssl rand -base64 12)\n$ hash=$(echo -n \"$password$salt\" | sha256sum)\nfor i in {1..1000}; do\n    hash=$(echo -n \"$hash\" | sha256sum)\ndone\necho $hash<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>4. \u4f7f\u7528Linux\u7cfb\u7edf\u63d0\u4f9b\u7684\u5b89\u5168\u5b58\u50a8\u65b9\u5f0f<\/strong><\/p>\n<p>Linux\u7cfb\u7edf\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5b89\u5168\u7684\u5b58\u50a8\u65b9\u5f0f\uff0c\u7528\u4e8e\u5b58\u50a8\u7528\u6237\u5bc6\u7801\uff0c\u5982\/etc\/shadow\u6587\u4ef6\u3002\u8fd9\u4e2a\u6587\u4ef6\u53ea\u6709root\u7528\u6237\u53ef\u8bfb\uff0c\u5e76\u4e14\u4fdd\u5b58\u4e86\u7528\u6237\u7684\u5bc6\u7801\u54c8\u5e0c\u503c\u548c\u5176\u4ed6\u76f8\u5173\u4fe1\u606f\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u5728\/etc\/shadow\u6587\u4ef6\u4e2d\u67e5\u627e\u5e76\u4fee\u6539\u7528\u6237\u5bc6\u7801\uff1a<\/p>\n<pre>$ sudo cat \/etc\/shadow | grep username\n$ sudo passwd username<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>5. \u6ce8\u610f\u4fdd\u62a4\u5bc6\u7801\u7684\u4f20\u8f93\u548c\u5b58\u50a8<\/strong><\/p>\n<p>\u65e0\u8bba\u662f\u5728\u6587\u4ef6\u4e2d\u5b58\u50a8\u5bc6\u7801\uff0c\u8fd8\u662f\u5728\u7f51\u7edc\u4e2d\u4f20\u8f93\u5bc6\u7801\uff0c\u90fd\u9700\u8981\u6ce8\u610f\u4fdd\u62a4\u5bc6\u7801\u7684\u5b89\u5168\u6027\u3002\u5efa\u8bae\u4f7f\u7528\u52a0\u5bc6\u7684\u65b9\u5f0f\u4f20\u8f93\u5bc6\u7801\uff0c\u5982\u4f7f\u7528SSH\u534f\u8bae\u8fdb\u884c\u8fdc\u7a0b\u8bbf\u95ee\u3002<\/p>\n<p>\u603b\u7684\u6765\u8bf4\uff0c\u4fdd\u62a4\u7528\u6237\u5bc6\u7801\u662f\u7ef4\u62a4\u7cfb\u7edf\u5b89\u5168\u7684\u5173\u952e\u4e00\u73af\u3002\u901a\u8fc7\u91c7\u53d6\u4e0a\u8ff0\u6700\u4f73\u5b9e\u8df5\uff0c\u53ef\u4ee5\u786e\u4fdd\u5bc6\u7801\u7684\u5b89\u5168\u6027\uff0c\u5e76\u6709\u6548\u9632\u8303\u6f5c\u5728\u7684\u5b89\u5168\u98ce\u9669\u3002\u5e0c\u671b\u672c\u6587\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<p>\u3010\u672c\u6587\u4ec5\u4f9b\u53c2\u8003\uff0c\u5177\u4f53\u64cd\u4f5c\u9700\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8fdb\u884c\u8c03\u6574\u3011<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fLinux\u7528\u6237\u5bc6\u7801\u5b58\u653e\u4f4d\u7f6e\u7684\u6700\u4f73\u5b9e\u8df5\u6307\u5357\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux\u7528\u6237\u5bc6\u7801\u5b58\u653e\u4f4d\u7f6e\u7684\u6700\u4f73\u5b9e\u8df5\u6307\u5357 \u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u7528\u6237\u5bc6\u7801\u7684\u5b58\u653e\u662f\u4e00\u9879\u81f3\u5173\u91cd\u8981\u7684\u5b89\u5168\u63aa\u65bd\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u4e00\u4e9bLinux\u7cfb\u7edf\u4e2d\u7528\u6237\u5bc6\u7801\u5b58\u653e\u7684\u6700\u4f73\u5b9e\u8df5\uff0c\u4ee5\u786e\u4fdd\u5bc6\u7801\u7684\u5b89\u5168\u6027\uff0c\u5e76\u63d0\u4f9b\u5177\u4f53\u7684\u4ee3\u7801\u793a\u4f8b\u7528\u4e8e\u53c2\u8003\u3002 1. \u4f7f\u7528\u52a0\u5bc6\u7b97\u6cd5\u5b58\u50a8\u5bc6\u7801 Linux\u7cfb\u7edf\u901a\u5e38\u4f1a\u4f7f\u7528\u52a0\u5bc6\u7b97\u6cd5\u5bf9\u7528\u6237\u5bc6\u7801\u8fdb\u884c\u5b58\u50a8\uff0c\u4ee5\u786e\u4fdd\u5bc6\u7801\u5728\u5b58\u50a8\u548c\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u7684\u5b89\u5168\u6027\u3002\u5e38\u89c1\u7684\u52a0\u5bc6\u7b97\u6cd5\u5305\u62ecMD5\u3001SHA-256\u7b49\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u4f7f\u7528SHA-256\u7b97\u6cd5\u5bf9\u7528\u6237\u5bc6\u7801\u8fdb\u884c\u52a0\u5bc6\uff1a $ echo -n &#8216;mysecurepassword&#8217; | sha256sum \u767b\u5f55\u540e\u590d\u5236 2. \u4f7f\u7528salt\u589e\u52a0\u5bc6\u7801\u7684\u5b89\u5168\u6027 \u4e3a\u4e86\u589e\u52a0\u5bc6\u7801\u7684\u5b89\u5168\u6027\uff0c\u53ef\u4ee5\u4f7f\u7528\u968f\u673a\u751f\u6210\u7684salt\u503c\u8fdb\u884c\u5bc6\u7801\u52a0\u5bc6\u3002salt\u662f\u4e00\u4e2a\u968f\u673a\u751f\u6210\u7684\u5b57\u7b26\u4e32\uff0c\u88ab\u6dfb\u52a0\u5230\u5bc6\u7801\u4e2d\uff0c\u53ef\u4ee5\u9632\u6b62\u76f8\u540c\u7684\u5bc6\u7801\u5bf9\u5e94\u76f8\u540c\u7684\u52a0\u5bc6\u7ed3\u679c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u4f7f\u7528salt\u503c\u5bf9\u5bc6\u7801\u8fdb\u884c\u52a0\u5bc6\uff1a $ password=&#8217;mysecurepassword&#8217; $ salt=$(openssl rand -base64 12) $ echo -n &#8220;$password$salt&#8221; | sha256sum \u767b\u5f55\u540e\u590d\u5236 3. \u4f7f\u7528\u6563\u5217\u548c\u8fed\u4ee3\u6b21\u6570\u52a0\u5f3a\u5bc6\u7801\u7684\u5b89\u5168\u6027 \u4e3a\u4e86\u589e\u5f3a\u5bc6\u7801\u7684\u5b89\u5168\u6027\uff0c\u53ef\u4ee5\u901a\u8fc7\u591a\u6b21\u8fed\u4ee3\u5bf9\u5bc6\u7801\u8fdb\u884c\u52a0\u5bc6\u3002\u8fd9\u6837\u53ef\u4ee5\u589e\u52a0\u7834\u89e3\u5bc6\u7801\u7684\u96be\u5ea6\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u5bf9\u5bc6\u7801\u8fdb\u884c\u591a\u6b21\u8fed\u4ee3\u52a0\u5bc6\uff1a $ password=&#8217;mysecurepassword&#8217; $ salt=$(openssl rand -base64 12) $ hash=$(echo -n &#8220;$password$salt&#8221; | sha256sum) for i in {1..1000}; do hash=$(echo -n &#8220;$hash&#8221; | sha256sum) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-17803","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/17803","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=17803"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/17803\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=17803"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=17803"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=17803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}