{"id":16574,"date":"2024-11-18T08:14:06","date_gmt":"2024-11-18T00:14:06","guid":{"rendered":"https:\/\/fwq.ai\/blog\/16574\/"},"modified":"2024-11-18T08:14:06","modified_gmt":"2024-11-18T00:14:06","slug":"linux-%e6%80%8e%e4%b9%88%e9%98%b2%e6%ad%a2-ssh-%e8%a2%ab%e6%9a%b4%e5%8a%9b%e7%a0%b4%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/16574\/","title":{"rendered":"Linux \u600e\u4e48\u9632\u6b62 ssh \u88ab\u66b4\u529b\u7834\u89e3"},"content":{"rendered":"<p> <br \/>\n<strong><span style=\"font-family: mp-quote, -apple-system-font, BlinkMacSystemFont,\"><strong><span style=\"letter-spacing: 1px\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/275\/013\/156a99986660e083cfbb7b815aba10d3-0.png\" class=\"aligncenter\" title=\"Linux \u600e\u4e48\u9632\u6b62 ssh \u88ab\u66b4\u529b\u7834\u89e3\u63d2\u56fe\" alt=\"Linux \u600e\u4e48\u9632\u6b62 ssh \u88ab\u66b4\u529b\u7834\u89e3\u63d2\u56fe\" \/><br \/><\/span><\/strong><\/span><\/strong><br \/>\n<span style=\"margin: 0px;padding: 0px;max-width: 100%\">SSH \u662f\u4e00\u79cd\u5e7f\u6cdb\u4f7f\u7528\u7684\u534f\u8bae\uff0c\u7528\u4e8e\u5b89\u5168\u5730\u8bbf\u95ee Linux \u670d\u52a1\u5668\u3002\u5927\u591a\u6570\u7528\u6237\u4f7f\u7528\u9ed8\u8ba4\u8bbe\u7f6e\u7684 SSH \u8fde\u63a5\u6765\u8fde\u63a5\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\u3002\u4f46\u662f\uff0c\u4e0d\u5b89\u5168\u7684\u9ed8\u8ba4\u914d\u7f6e\u4e5f\u4f1a\u5e26\u6765\u5404\u79cd\u5b89\u5168\u98ce\u9669\u3002<\/span><br \/>\n<span style=\"margin: 0px;padding: 0px;max-width: 100%\">\u5177\u6709\u5f00\u653e SSH \u8bbf\u95ee\u6743\u9650\u7684\u670d\u52a1\u5668\u7684 root \u5e10\u6237\u53ef\u80fd\u5b58\u5728\u98ce\u9669\u3002\u5c24\u5176\u662f\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u516c\u5171 IP \u5730\u5740\uff0c\u5219\u7834\u89e3 root \u5bc6\u7801\u8981\u5bb9\u6613\u5f97\u591a\u3002\u56e0\u6b64\uff0c\u6709\u5fc5\u8981\u4e86\u89e3 SSH \u5b89\u5168\u6027\u3002<\/span><br \/>\n<span style=\"margin: 0px;padding: 0px;max-width: 100%\">\u8fd9\u662f\u5728 Linux \u4e0a\u4fdd\u62a4 SSH \u670d\u52a1\u5668\u8fde\u63a5\u7684\u65b9\u6cd5\u3002<\/span>  <\/p>\n<h3>1. \u7981\u7528 root \u7528\u6237\u767b\u5f55<\/h3>\n<p><span style=\"margin: 0px;padding: 0px;max-width: 100%\">\u4e3a\u6b64\uff0c\u9996\u5148\uff0c\u7981\u7528 root \u7528\u6237\u7684 SSH \u8bbf\u95ee\u5e76\u521b\u5efa\u4e00\u4e2a\u5177\u6709 root \u6743\u9650\u7684\u65b0\u7528\u6237\u3002\u5173\u95ed root \u7528\u6237\u7684\u670d\u52a1\u5668\u8bbf\u95ee\u662f\u4e00\u79cd\u9632\u5fa1\u7b56\u7565\uff0c\u53ef\u4ee5\u9632\u6b62\u653b\u51fb\u8005\u5b9e\u73b0\u5165\u4fb5\u7cfb\u7edf\u7684\u76ee\u6807\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a exampleroot \u7684\u7528\u6237\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/span>   <\/p>\n<pre>useradd&nbsp;-m&nbsp;examplerootpasswd&nbsp;examplerootusermod&nbsp;-aG&nbsp;sudo&nbsp;exampleroot<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236    \u4ee5\u4e0b\u662f\u4e0a\u8ff0\u547d\u4ee4\u7684\u7b80\u8981\u8bf4\u660e\uff1a  <\/p>\n<ul>\n<li>\n<p style=\"margin: 5px 0px 24px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;text-align: left;font-weight: 500;line-height: 1.75em\">useradd \u521b\u5efa\u4e00\u4e2a\u65b0\u7528\u6237\uff0c\u5e76\u4e14 &#8211; m \u53c2\u6570\u5728\u4f60\u521b\u5efa\u7684\u7528\u6237\u7684\u4e3b\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\u5939\u3002<\/p>\n<\/li>\n<li>\n<p style=\"margin: 5px 0px 24px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;text-align: left;font-weight: 500;line-height: 1.75em\">passwd \u547d\u4ee4\u7528\u4e8e\u4e3a\u65b0\u7528\u6237\u5206\u914d\u5bc6\u7801\u3002\u8bf7\u8bb0\u4f4f\uff0c\u4f60\u5206\u914d\u7ed9\u7528\u6237\u7684\u5bc6\u7801\u5e94\u8be5\u5f88\u590d\u6742\u4e14\u96be\u4ee5\u731c\u6d4b\u3002<\/p>\n<\/li>\n<li>\n<p style=\"margin: 5px 0px 24px;padding: 0px;max-width: 100%;clear: both;min-height: 1em;text-align: left;font-weight: 500;line-height: 1.75em\">usermod -aG sudo \u5c06\u65b0\u521b\u5efa\u7684\u7528\u6237\u6dfb\u52a0\u5230\u7ba1\u7406\u5458\u7ec4\u3002<\/p>\n<\/li>\n<\/ul>\n<p><span style=\"margin: 0px;padding: 0px;max-width: 100%\">\u5728\u7528\u6237\u521b\u5efa\u8fc7\u7a0b\u4e4b\u540e\uff0c\u9700\u8981\u5bf9 sshd_config \u6587\u4ef6\u8fdb\u884c\u4e00\u4e9b\u66f4\u6539\u3002\u4f60\u53ef\u4ee5\u5728 \/ etc\/ssh\/sshd_config \u627e\u5230\u6b64\u6587\u4ef6\u3002\u4f7f\u7528\u4efb\u4f55\u6587\u672c\u7f16\u8f91\u5668\u6253\u5f00\u6587\u4ef6\u5e76\u5bf9\u5176\u8fdb\u884c\u4ee5\u4e0b\u66f4\u6539\uff1a<\/span>   <\/p>\n<pre>#&nbsp;Authentication:&nbsp;#LoginGraceTime&nbsp;2m&nbsp;PermitRootLogin&nbsp;no&nbsp;AllowUsers&nbsp;exampleroot<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236<br \/>\n<span style=\"margin: 0px;padding: 0px;max-width: 100%\">PermitRootLogin \u884c\u5c06\u963b\u6b62 root \u7528\u6237\u4f7f\u7528 SSH \u83b7\u5f97\u8fdc\u7a0b\u8bbf\u95ee\u3002\u5728 AllowUsers \u5217\u8868\u4e2d\u5305\u542b exampleroot \u4f1a\u5411\u7528\u6237\u6388\u4e88\u5fc5\u8981\u7684\u6743\u9650\u3002<\/span><br \/>\n<span style=\"margin: 0px;padding: 0px;max-width: 100%\">\u6700\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u91cd\u542f SSH \u670d\u52a1\uff1a<\/span>   <\/p>\n<pre>&amp;gt;&nbsp;rumenz@rumenz&nbsp;\/home\/rumenz\/www.rumenz.com&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;gt;&nbsp;sudo&nbsp;systemctl&nbsp;restart&nbsp;ssh<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236<br \/>\n<span style=\"margin: 0px;padding: 0px;max-width: 100%\">\u5982\u679c\u5931\u8d25\u5e76\u4e14\u4f60\u6536\u5230\u9519\u8bef\u6d88\u606f\uff0c\u8bf7\u5c1d\u8bd5\u4ee5\u4e0b\u547d\u4ee4\u3002\u8fd9\u53ef\u80fd\u56e0\u4f60\u4f7f\u7528\u7684 Linux \u53d1\u884c\u7248\u800c\u5f02\u3002\u53e6\u5916\uff0c\u641c\u7d22\u516c\u4f17\u53f7Linux\u5c31\u8be5\u8fd9\u6837\u5b66\u540e\u53f0\u56de\u590d\u201cLinux\u201d\uff0c\u83b7\u53d6\u4e00\u4efd\u60ca\u559c\u793c\u5305\u3002<\/span>   <\/p>\n<pre>&amp;gt;&nbsp;rumenz@rumenz&nbsp;\/home\/rumenz\/www.rumenz.com&amp;gt;&nbsp;sudo&nbsp;systemctl&nbsp;restart&nbsp;sshd<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h3>2. \u66f4\u6539\u9ed8\u8ba4\u7aef\u53e3<\/h3>\n<p><span style=\"margin: 0px;padding: 0px;max-width: 100%\">\u9ed8\u8ba4\u7684 SSH \u8fde\u63a5\u7aef\u53e3\u662f 22\u3002\u5f53\u7136\uff0c\u6240\u6709\u7684\u653b\u51fb\u8005\u90fd\u77e5\u9053\u8fd9\u4e00\u70b9\uff0c\u56e0\u6b64\u9700\u8981\u66f4\u6539\u9ed8\u8ba4\u7aef\u53e3\u53f7\u4ee5\u786e\u4fdd SSH \u5b89\u5168\u3002\u5c3d\u7ba1\u653b\u51fb\u8005\u53ef\u4ee5\u901a\u8fc7 Nmap \u626b\u63cf\u8f7b\u677e\u627e\u5230\u65b0\u7684\u7aef\u53e3\u53f7\uff0c\u4f46\u8fd9\u91cc\u7684\u76ee\u6807\u662f\u8ba9\u653b\u51fb\u8005\u7684\u5de5\u4f5c\u66f4\u52a0\u56f0\u96be\u3002<\/span><br \/>\n<span style=\"margin: 0px;padding: 0px;max-width: 100%\">\u8981\u66f4\u6539\u7aef\u53e3\u53f7\uff0c\u8bf7\u6253\u5f00 \/ etc\/ssh\/sshd_config \u5e76\u5bf9\u6587\u4ef6\u8fdb\u884c\u4ee5\u4e0b\u66f4\u6539\uff1a<\/span>   <\/p>\n<pre>Include&nbsp;\/etc\/ssh\/sshd_config.d\/*.confPort&nbsp;22099<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236<br \/>\n<span style=\"margin: 0px;padding: 0px;max-width: 100%\">\u5728\u8fd9\u4e00\u6b65\u4e4b\u540e\uff0c\u4f7f\u7528 sudo systemctl restart ssh \u518d\u6b21\u91cd\u542f SSH \u670d\u52a1\u3002\u73b0\u5728\u4f60\u53ef\u4ee5\u4f7f\u7528\u521a\u521a\u5b9a\u4e49\u7684\u7aef\u53e3\u8bbf\u95ee\u4f60\u7684\u670d\u52a1\u5668\u3002\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u9632\u706b\u5899\uff0c\u5219\u8fd8\u5fc5\u987b\u5728\u6b64\u5904\u8fdb\u884c\u5fc5\u8981\u7684\u89c4\u5219\u66f4\u6539\u3002\u5728\u8fd0\u884c netstat -tlpn \u547d\u4ee4\u65f6\uff0c\u4f60\u53ef\u4ee5\u770b\u5230\u4f60\u7684 SSH \u7aef\u53e3\u53f7\u5df2\u66f4\u6539\u3002<\/span>  <\/p>\n<h3>3. \u7981\u6b62\u4f7f\u7528\u7a7a\u767d\u5bc6\u7801\u7684\u7528\u6237\u8bbf\u95ee<\/h3>\n<p><span style=\"margin: 0px;padding: 0px;max-width: 100%\">\u5728\u4f60\u7684\u7cfb\u7edf\u4e0a\u53ef\u80fd\u6709\u4f60\u4e0d\u5c0f\u5fc3\u521b\u5efa\u7684\u6ca1\u6709\u5bc6\u7801\u7684\u7528\u6237\u3002\u8981\u9632\u6b62\u6b64\u7c7b\u7528\u6237\u8bbf\u95ee\u670d\u52a1\u5668\uff0c\u4f60\u53ef\u4ee5\u5c06 sshd_config \u6587\u4ef6\u4e2d\u7684 PermitEmptyPasswords \u884c\u503c\u8bbe\u7f6e\u4e3a no\u3002<\/span>   <\/p>\n<pre>PermitEmptyPasswords&nbsp;no<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h3>4. \u9650\u5236\u767b\u5f55 \/ \u8bbf\u95ee\u5c1d\u8bd5<\/h3>\n<p><span style=\"margin: 0px;padding: 0px;max-width: 100%\">\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u9700\u8981\u5c1d\u8bd5\u591a\u6b21\u8f93\u5165\u5bc6\u7801\u6765\u8bbf\u95ee\u670d\u52a1\u5668\u3002\u4f46\u662f\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u5229\u7528\u6b64\u6f0f\u6d1e\u5bf9\u670d\u52a1\u5668\u8fdb\u884c\u66b4\u529b\u7834\u89e3\u3002\u901a\u8fc7\u6307\u5b9a\u5141\u8bb8\u7684\u5bc6\u7801\u5c1d\u8bd5\u6b21\u6570\uff0c\u4f60\u53ef\u4ee5\u5728\u5c1d\u8bd5\u4e00\u5b9a\u6b21\u6570\u540e\u81ea\u52a8\u7ec8\u6b62 SSH \u8fde\u63a5\u3002<\/span>   <\/p>\n<pre>\u725b\u903c\u554a\uff01\u63a5\u79c1\u6d3b\u5fc5\u5907\u7684&nbsp;N&nbsp;\u4e2a\u5f00\u6e90\u9879\u76ee\uff01\u8d76\u5feb\u6536\u85cf\u5427<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236<br \/>\n<span style=\"margin: 0px;padding: 0px;max-width: 100%\"><\/span><br \/>\n<span style=\"margin: 0px;padding: 0px;max-width: 100%\">\u4e3a\u6b64\uff0c\u8bf7\u66f4\u6539 sshd_config \u6587\u4ef6\u4e2d\u7684 MaxAuthTries \u503c\u3002<\/span>   <\/p>\n<pre>MaxAuthTries&nbsp;3<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h3>5. \u4f7f\u7528 SSH \u7248\u672c 2<\/h3>\n<p><span style=\"margin: 0px;padding: 0px;max-width: 100%\">SSH \u7684\u7b2c\u4e8c\u4e2a\u7248\u672c\u53d1\u5e03\u662f\u56e0\u4e3a\u7b2c\u4e00\u4e2a\u7248\u672c\u4e2d\u5b58\u5728\u8bb8\u591a\u6f0f\u6d1e\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u5c06 Protocol \u53c2\u6570\u6dfb\u52a0\u5230 sshd_config \u6587\u4ef6\u6765\u542f\u7528\u670d\u52a1\u5668\u4f7f\u7528\u7b2c\u4e8c\u4e2a\u7248\u672c\u3002\u8fd9\u6837\uff0c\u4f60\u672a\u6765\u7684\u6240\u6709\u8fde\u63a5\u90fd\u5c06\u4f7f\u7528\u7b2c\u4e8c\u4e2a\u7248\u672c\u7684 SSH\u3002<\/span>   <\/p>\n<pre>Include&nbsp;\/etc\/ssh\/sshd_config.d\/*.conf&nbsp;Protocol&nbsp;2<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h3>6. \u5173\u95ed TCP \u7aef\u53e3\u8f6c\u53d1\u548c X11 \u8f6c\u53d1<\/h3>\n<p><span style=\"margin: 0px;padding: 0px;max-width: 100%\">\u653b\u51fb\u8005\u53ef\u4ee5\u5c1d\u8bd5\u901a\u8fc7 SSH \u8fde\u63a5\u7684\u7aef\u53e3\u8f6c\u53d1\u6765\u8bbf\u95ee\u4f60\u7684\u5176\u4ed6\u7cfb\u7edf\u3002\u4e3a\u4e86\u9632\u6b62\u8fd9\u79cd\u60c5\u51b5\uff0c\u4f60\u53ef\u4ee5\u5728 sshd_config \u6587\u4ef6\u4e2d\u5173\u95ed AllowTcpForwarding \u548c X11Forwarding \u529f\u80fd\u3002<\/span>   <\/p>\n<pre>X11Forwarding&nbsp;no&nbsp;\nAllowTcpForwarding&nbsp;no<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h3>7. \u4f7f\u7528 SSH \u5bc6\u94a5\u8fde\u63a5<\/h3>\n<p><span style=\"margin: 0px;padding: 0px;max-width: 100%\">\u8fde\u63a5\u5230\u670d\u52a1\u5668\u7684\u6700\u5b89\u5168\u65b9\u6cd5\u4e4b\u4e00\u662f\u4f7f\u7528 SSH \u5bc6\u94a5\u3002\u4f7f\u7528 SSH \u5bc6\u94a5\u65f6\uff0c\u65e0\u9700\u5bc6\u7801\u5373\u53ef\u8bbf\u95ee\u670d\u52a1\u5668\u3002\u53e6\u5916\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u66f4\u6539 sshd_config \u6587\u4ef6\u4e2d\u4e0e\u5bc6\u7801\u76f8\u5173\u7684\u53c2\u6570\u6765\u5b8c\u5168\u5173\u95ed\u5bf9\u670d\u52a1\u5668\u7684\u5bc6\u7801\u8bbf\u95ee\u3002<\/span><br \/>\n<span style=\"margin: 0px;padding: 0px;max-width: 100%\">\u521b\u5efa SSH \u5bc6\u94a5\u65f6\uff0c\u6709\u4e24\u4e2a\u5bc6\u94a5\uff1aPublic \u548c Private\u3002\u516c\u94a5\u5c06\u4e0a\u4f20\u5230\u4f60\u8981\u8fde\u63a5\u7684\u670d\u52a1\u5668\uff0c\u800c\u79c1\u94a5\u5219\u5b58\u50a8\u5728\u4f60\u5c06\u7528\u6765\u5efa\u7acb\u8fde\u63a5\u7684\u8ba1\u7b97\u673a\u4e0a\u3002<\/span><br \/>\n<span style=\"margin: 0px;padding: 0px;max-width: 100%\">\u5728\u4f60\u7684\u8ba1\u7b97\u673a\u4e0a\u4f7f\u7528 ssh-keygen \u547d\u4ee4\u521b\u5efa SSH \u5bc6\u94a5\u3002\u4e0d\u8981\u5c06\u5bc6\u7801\u77ed\u8bed\u5b57\u6bb5\u7559\u7a7a\u5e76\u8bb0\u4f4f\u4f60\u5728\u6b64\u5904\u8f93\u5165\u7684\u5bc6\u7801\u3002\u5982\u679c\u5c06\u5176\u7559\u7a7a\uff0c\u4f60\u5c06\u53ea\u80fd\u4f7f\u7528 SSH \u5bc6\u94a5\u6587\u4ef6\u8bbf\u95ee\u5b83\u3002\u4f46\u662f\uff0c\u5982\u679c\u4f60\u8bbe\u7f6e\u4e86\u5bc6\u7801\uff0c\u5219\u53ef\u4ee5\u9632\u6b62\u62e5\u6709\u5bc6\u94a5\u6587\u4ef6\u7684\u653b\u51fb\u8005\u8bbf\u95ee\u5b83\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa SSH \u5bc6\u94a5\uff1a<\/span>   <\/p>\n<pre>ssh-keygen<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h3>8. SSH \u8fde\u63a5\u7684 IP \u9650\u5236<\/h3>\n<p><span style=\"margin: 0px;padding: 0px;max-width: 100%\">\u5927\u591a\u6570\u60c5\u51b5\u4e0b\uff0c\u9632\u706b\u5899\u4f7f\u7528\u81ea\u5df1\u7684\u6807\u51c6\u6846\u67b6\u963b\u6b62\u8bbf\u95ee\uff0c\u65e8\u5728\u4fdd\u62a4\u670d\u52a1\u5668\u3002\u4f46\u662f\uff0c\u8fd9\u5e76\u4e0d\u603b\u662f\u8db3\u591f\u7684\uff0c\u4f60\u9700\u8981\u589e\u52a0\u8fd9\u79cd\u5b89\u5168\u6f5c\u529b\u3002<\/span><br \/>\n<span style=\"margin: 0px;padding: 0px;max-width: 100%\">\u4e3a\u6b64\uff0c\u8bf7\u6253\u5f00 \/ etc\/hosts.allow \u6587\u4ef6\u3002\u901a\u8fc7\u5bf9\u8be5\u6587\u4ef6\u8fdb\u884c\u7684\u6dfb\u52a0\uff0c\u4f60\u53ef\u4ee5\u9650\u5236 SSH \u6743\u9650\uff0c\u5141\u8bb8\u7279\u5b9a IP \u5757\uff0c\u6216\u8f93\u5165\u5355\u4e2a IP \u5e76\u4f7f\u7528\u62d2\u7edd\u547d\u4ee4\u963b\u6b62\u6240\u6709\u5269\u4f59\u7684 IP \u5730\u5740\u3002<\/span><br \/>\n<span style=\"margin: 0px;padding: 0px;max-width: 100%\">\u4e0b\u9762\u4f60\u5c06\u770b\u5230\u4e00\u4e9b\u793a\u4f8b\u8bbe\u7f6e\u3002\u5b8c\u6210\u8fd9\u4e9b\u4e4b\u540e\uff0c\u50cf\u5f80\u5e38\u4e00\u6837\u91cd\u65b0\u542f\u52a8 SSH \u670d\u52a1\u4ee5\u4fdd\u5b58\u66f4\u6539\u3002<\/span>   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fLinux \u600e\u4e48\u9632\u6b62 ssh \u88ab\u66b4\u529b\u7834\u89e3\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>SSH \u662f\u4e00\u79cd\u5e7f\u6cdb\u4f7f\u7528\u7684\u534f\u8bae\uff0c\u7528\u4e8e\u5b89\u5168\u5730\u8bbf\u95ee Linux \u670d\u52a1\u5668\u3002\u5927\u591a\u6570\u7528\u6237\u4f7f\u7528\u9ed8\u8ba4\u8bbe\u7f6e\u7684 SSH \u8fde\u63a5\u6765\u8fde\u63a5\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\u3002\u4f46\u662f\uff0c\u4e0d\u5b89\u5168\u7684\u9ed8\u8ba4\u914d\u7f6e\u4e5f\u4f1a\u5e26\u6765\u5404\u79cd\u5b89\u5168\u98ce\u9669\u3002 \u5177\u6709\u5f00\u653e SSH \u8bbf\u95ee\u6743\u9650\u7684\u670d\u52a1\u5668\u7684 root \u5e10\u6237\u53ef\u80fd\u5b58\u5728\u98ce\u9669\u3002\u5c24\u5176\u662f\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u516c\u5171 IP \u5730\u5740\uff0c\u5219\u7834\u89e3 root \u5bc6\u7801\u8981\u5bb9\u6613\u5f97\u591a\u3002\u56e0\u6b64\uff0c\u6709\u5fc5\u8981\u4e86\u89e3 SSH \u5b89\u5168\u6027\u3002 \u8fd9\u662f\u5728 Linux \u4e0a\u4fdd\u62a4 SSH \u670d\u52a1\u5668\u8fde\u63a5\u7684\u65b9\u6cd5\u3002 1. \u7981\u7528 root \u7528\u6237\u767b\u5f55 \u4e3a\u6b64\uff0c\u9996\u5148\uff0c\u7981\u7528 root \u7528\u6237\u7684 SSH \u8bbf\u95ee\u5e76\u521b\u5efa\u4e00\u4e2a\u5177\u6709 root \u6743\u9650\u7684\u65b0\u7528\u6237\u3002\u5173\u95ed root \u7528\u6237\u7684\u670d\u52a1\u5668\u8bbf\u95ee\u662f\u4e00\u79cd\u9632\u5fa1\u7b56\u7565\uff0c\u53ef\u4ee5\u9632\u6b62\u653b\u51fb\u8005\u5b9e\u73b0\u5165\u4fb5\u7cfb\u7edf\u7684\u76ee\u6807\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a exampleroot \u7684\u7528\u6237\uff0c\u5982\u4e0b\u6240\u793a\uff1a useradd&nbsp;-m&nbsp;examplerootpasswd&nbsp;examplerootusermod&nbsp;-aG&nbsp;sudo&nbsp;exampleroot \u767b\u5f55\u540e\u590d\u5236 \u4ee5\u4e0b\u662f\u4e0a\u8ff0\u547d\u4ee4\u7684\u7b80\u8981\u8bf4\u660e\uff1a useradd \u521b\u5efa\u4e00\u4e2a\u65b0\u7528\u6237\uff0c\u5e76\u4e14 &#8211; m \u53c2\u6570\u5728\u4f60\u521b\u5efa\u7684\u7528\u6237\u7684\u4e3b\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\u5939\u3002 passwd \u547d\u4ee4\u7528\u4e8e\u4e3a\u65b0\u7528\u6237\u5206\u914d\u5bc6\u7801\u3002\u8bf7\u8bb0\u4f4f\uff0c\u4f60\u5206\u914d\u7ed9\u7528\u6237\u7684\u5bc6\u7801\u5e94\u8be5\u5f88\u590d\u6742\u4e14\u96be\u4ee5\u731c\u6d4b\u3002 usermod -aG sudo \u5c06\u65b0\u521b\u5efa\u7684\u7528\u6237\u6dfb\u52a0\u5230\u7ba1\u7406\u5458\u7ec4\u3002 \u5728\u7528\u6237\u521b\u5efa\u8fc7\u7a0b\u4e4b\u540e\uff0c\u9700\u8981\u5bf9 sshd_config \u6587\u4ef6\u8fdb\u884c\u4e00\u4e9b\u66f4\u6539\u3002\u4f60\u53ef\u4ee5\u5728 \/ [&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-16574","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/16574","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=16574"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/16574\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=16574"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=16574"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=16574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}