{"id":2160,"date":"2025-08-08T22:26:48","date_gmt":"2025-08-08T14:26:48","guid":{"rendered":"https:\/\/www.hgfwq.com\/blog\/?p=2160"},"modified":"2025-08-08T22:26:48","modified_gmt":"2025-08-08T14:26:48","slug":"%e4%b8%ba%e4%bd%95%e6%9b%b4%e6%94%b9-ssh-%e7%ab%af%e5%8f%a3%e6%98%af%e4%bf%9d%e6%8a%a4%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%ae%89%e5%85%a8%e7%9a%84%e9%87%8d%e8%a6%81%e6%8e%aa%e6%96%bd","status":"publish","type":"post","link":"https:\/\/www.hgfwq.com\/blog\/2160.html","title":{"rendered":"\u4e3a\u4f55\u66f4\u6539 SSH \u7aef\u53e3\u662f\u4fdd\u62a4\u670d\u52a1\u5668\u5b89\u5168\u7684\u91cd\u8981\u63aa\u65bd"},"content":{"rendered":"<p><h>\u66f4\u6539 SSH \u7aef\u53e3\u2014\u2014\u63d0\u9ad8\u670d\u52a1\u5668\u5b89\u5168\u6027\u7684\u5b9e\u7528\u6307\u5357<\/h><\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.hgfwq.com\/blog\/wp-content\/uploads\/2025\/07\/6hv4ORZ.jpg\" alt=\"\u4e3a\u4f55\u66f4\u6539 SSH \u7aef\u53e3\u662f\u4fdd\u62a4\u670d\u52a1\u5668\u5b89\u5168\u7684\u91cd\u8981\u63aa\u65bd\" title=\"\u4e3a\u4f55\u66f4\u6539 SSH \u7aef\u53e3\u662f\u4fdd\u62a4\u670d\u52a1\u5668\u5b89\u5168\u7684\u91cd\u8981\u63aa\u65bd\"><\/p>\n<p><p>\u5728\u670d\u52a1\u5668\u7ba1\u7406\u4e2d\uff0c\u66f4\u6539 SSH \u7aef\u53e3\u662f\u4e00\u79cd\u5e38\u89c1\u4e14\u6709\u6548\u7684\u5b89\u5168\u63aa\u65bd\u3002\u901a\u8fc7\u5c06\u9ed8\u8ba4\u7684 SSH \u7aef\u53e3\uff0822\uff09\u66f4\u6539\u4e3a\u4e00\u4e2a\u4e0d\u5e38\u7528\u7684\u7aef\u53e3\uff0c\u53ef\u4ee5\u51cf\u5c11\u6f5c\u5728\u7684\u5b89\u5168\u98ce\u9669\uff0c\u56e0\u4e3a\u653b\u51fb\u8005\u901a\u5e38\u4f1a\u9996\u5148\u5c1d\u8bd5\u9ed8\u8ba4\u7aef\u53e3\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u8be6\u7ec6\u7684\u6307\u5357\uff0c\u5e2e\u52a9\u60a8\u5728\u670d\u52a1\u5668\u4e0a\u66f4\u6539 SSH \u7aef\u53e3\u3002<\/p>\n<\/p>\n<p><h>1. \u51c6\u5907\u5de5\u4f5c<\/h1>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u6709\u4ee5\u4e0b\u51c6\u5907\u5de5\u4f5c\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u8fdc\u7a0b\u8bbf\u95ee\u6743\u9650\uff1a\u786e\u4fdd\u60a8\u6709\u6743\u9650\u8fdc\u7a0b\u8bbf\u95ee\u60a8\u7684\u670d\u52a1\u5668\u3002<\/li>\n<li>SSH \u5ba2\u6237\u7aef\uff1a\u5b89\u88c5\u5e76\u914d\u7f6e\u597d SSH \u5ba2\u6237\u7aef\uff0c\u5982 PuTTY\u3002<\/li>\n<li>\u670d\u52a1\u5668\u7ba1\u7406\u5458\u6743\u9650\uff1a\u4ee5 root \u7528\u6237\u8eab\u4efd\u8fdb\u884c\u64cd\u4f5c\uff0c\u6216\u8005\u6709\u8db3\u591f\u7684\u6743\u9650\u6765\u66f4\u6539\u7aef\u53e3\u8bbe\u7f6e\u3002<\/li>\n<\/ul>\n<p><h>2. \u68c0\u67e5\u5f53\u524d SSH \u7aef\u53e3\u914d\u7f6e<\/h1>\n<\/p>\n<p><p>\u5728\u66f4\u6539\u7aef\u53e3\u4e4b\u524d\uff0c\u5148\u68c0\u67e5\u5f53\u524d SSH \u7684\u7aef\u53e3\u914d\u7f6e\u3002<\/p>\n<\/p>\n<p><pre><\/p>\r\n<p>sudo cat \/etc\/ssh\/sshd_config<\/p>\r\n<p><\/pre>\n<\/p>\n<p><p>\u60a8\u4f1a\u770b\u5230\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684 `Port` \u884c\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u5e94\u8be5\u662f `Port 22`\u3002<\/p>\n<\/p>\n<p><h>3. \u66f4\u6539 SSH \u7aef\u53e3<\/h1>\n<\/p>\n<p><p>\u7f16\u8f91 SSH \u914d\u7f6e\u6587\u4ef6\uff0c\u66f4\u6539\u7aef\u53e3\u53f7\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6253\u5f00\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><\/p>\r\n<p>sudo nano \/etc\/ssh\/sshd_config<\/p>\r\n<p><\/pre>\n<\/p>\n<p><p>\u627e\u5230 `Port` \u884c\uff0c\u5c06\u5176\u4fee\u6539\u4e3a\u60a8\u9009\u62e9\u7684\u7aef\u53e3\u53f7\uff0c\u4f8b\u5982 `Port 2222`\u3002\u786e\u4fdd\u60a8\u9009\u62e9\u7684\u7aef\u53e3\u53f7\u4e0d\u5728\u5176\u4ed6\u670d\u52a1\u4e2d\u5360\u7528\u3002<\/p>\n<\/p>\n<p><h>4. \u4fdd\u5b58\u5e76\u9000\u51fa\u7f16\u8f91\u5668<\/h1>\n<\/p>\n<p><p>\u66f4\u6539\u5b8c\u6210\u540e\uff0c\u4fdd\u5b58\u5e76\u9000\u51fa\u7f16\u8f91\u5668\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f nano \u7f16\u8f91\u5668\uff0c\u53ef\u4ee5\u6309 `Ctrl + O` \u4fdd\u5b58\uff0c\u7136\u540e\u6309 `Ctrl + X` \u9000\u51fa\u3002<\/p>\n<\/p>\n<p><h>5. \u91cd\u542f SSH \u670d\u52a1<\/h1>\n<\/p>\n<p><p>\u4e3a\u4e86\u4f7f\u66f4\u6539\u751f\u6548\uff0c\u9700\u8981\u91cd\u542f SSH \u670d\u52a1\u3002<\/p>\n<\/p>\n<p><pre><\/p>\r\n<p>sudo systemctl restart ssh<\/p>\r\n<p><\/pre>\n<\/p>\n<p><p>\u6216\u8005\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff08\u6839\u636e\u60a8\u7684\u53d1\u884c\u7248\u53ef\u80fd\u6709\u6240\u4e0d\u540c\uff09\uff1a<\/p>\n<\/p>\n<p><pre><\/p>\r\n<p>sudo service ssh restart<\/p>\r\n<p><\/pre>\n<\/p>\n<p><h>6. \u9a8c\u8bc1 SSH \u7aef\u53e3\u66f4\u6539<\/h1>\n<\/p>\n<p><p>\u4f7f\u7528 SSH \u5ba2\u6237\u7aef\u5c1d\u8bd5\u8fde\u63a5\u5230\u65b0\u7684\u7aef\u53e3\u3002\u5982\u679c\u8fde\u63a5\u6210\u529f\uff0c\u8bf4\u660e\u66f4\u6539\u5df2\u7ecf\u751f\u6548\u3002<\/p>\n<\/p>\n<p><pre><\/p>\r\n<p>ssh -p 2222 \u7528\u6237\u540d@\u670d\u52a1\u5668IP\u5730\u5740<\/p>\r\n<p><\/pre>\n<\/p>\n<p><h>7. \u4fee\u6539 SSH \u914d\u7f6e\u6587\u4ef6\u7684\u9632\u706b\u5899\u89c4\u5219<\/h1>\n<\/p>\n<p><p>\u4e3a\u4e86\u786e\u4fdd\u65b0\u7684 SSH \u7aef\u53e3\u53ef\u4ee5\u901a\u8fc7\u9632\u706b\u5899\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u6dfb\u52a0\u4e00\u6761\u65b0\u7684\u89c4\u5219\u6765\u5141\u8bb8\u8be5\u7aef\u53e3\u7684\u6d41\u91cf\u3002<\/p>\n<\/p>\n<p><pre><\/p>\r\n<p>sudo firewall-cmd --zone=public --add-port=2222\/tcp<\/p>\r\n<p><\/pre>\n<\/p>\n<p><p>\u5bf9\u4e8e\u5176\u4ed6\u9632\u706b\u5899\u7ba1\u7406\u7cfb\u7edf\uff0c\u5982 iptables\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u4e0d\u540c\u7684\u547d\u4ee4\u6765\u6dfb\u52a0\u89c4\u5219\u3002<\/p>\n<\/p>\n<p><h>8. \u6ce8\u610f\u4e8b\u9879<\/h1>\n<\/p>\n<p><p>\u66f4\u6539 SSH \u7aef\u53e3\u540e\uff0c\u8bf7\u786e\u4fdd\u5c06\u65b0\u7684\u7aef\u53e3\u53f7\u901a\u77e5\u6240\u6709\u9700\u8981\u8bbf\u95ee\u670d\u52a1\u5668\u7684\u4eba\u3002\u6b64\u5916\uff0c\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f SSH \u5bc6\u94a5\u8ba4\u8bc1\uff0c\u8bf7\u786e\u4fdd\u5bc6\u94a5\u6587\u4ef6\u8def\u5f84\u6ca1\u6709\u6539\u53d8\u3002<\/p>\n<\/p>\n<p><h>\u5e38\u89c1\u95ee\u7b54<\/h1>\n<\/p>\n<p><b>\u95ee\uff1a\u4e3a\u4ec0\u4e48\u9700\u8981\u66f4\u6539 SSH \u7aef\u53e3\uff1f<\/b><\/p>\n<p><p>\u66f4\u6539 SSH \u7aef\u53e3\u53ef\u4ee5\u63d0\u9ad8\u670d\u52a1\u5668\u7684\u5b89\u5168\u6027\uff0c\u56e0\u4e3a\u9ed8\u8ba4\u7684 SSH \u7aef\u53e3\uff0822\uff09\u662f\u653b\u51fb\u8005\u9996\u5148\u5c1d\u8bd5\u7684\u76ee\u6807\u4e4b\u4e00\u3002<\/p>\n<\/p>\n<p><b>\u95ee\uff1a\u6211\u53ef\u4ee5\u5c06 SSH \u7aef\u53e3\u66f4\u6539\u56de\u9ed8\u8ba4\u7684 22 \u5417\uff1f<\/b><\/p>\n<p><p>\u5f53\u7136\u53ef\u4ee5\u3002\u5982\u679c\u60a8\u51b3\u5b9a\u5c06 SSH \u7aef\u53e3\u66f4\u6539\u56de\u9ed8\u8ba4\u503c\uff0c\u53ea\u9700\u6309\u7167\u4e0a\u8ff0\u6307\u5357\u8fdb\u884c\u64cd\u4f5c\uff0c\u5c06\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u7aef\u53e3\u53f7\u6539\u56de 22\uff0c\u7136\u540e\u91cd\u542f SSH \u670d\u52a1\u3002<\/p>\n<\/p>\n<p><b>\u95ee\uff1a\u66f4\u6539 SSH \u7aef\u53e3\u540e\uff0c\u5982\u4f55\u8ba9\u6240\u6709\u7528\u6237\u77e5\u9053\u65b0\u7684\u7aef\u53e3\u53f7\uff1f<\/b><\/p>\n<p><p>\u60a8\u53ef\u4ee5\u901a\u8fc7\u7535\u5b50\u90ae\u4ef6\u3001\u56e2\u961f\u4f1a\u8bae\u6216\u6587\u6863\u66f4\u65b0\u7b49\u65b9\u5f0f\u901a\u77e5\u6240\u6709\u9700\u8981\u8bbf\u95ee\u670d\u52a1\u5668\u7684\u7528\u6237\u3002\u786e\u4fdd\u4ed6\u4eec\u77e5\u9053\u65b0\u7684\u7aef\u53e3\u53f7\u548c\u4efb\u4f55\u53ef\u80fd\u5f71\u54cd\u8bbf\u95ee\u7684\u5176\u4ed6\u66f4\u6539\u3002<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u66f4\u6539 SSH \u7aef\u53e3\u2014\u2014\u63d0\u9ad8\u670d\u52a1\u5668\u5b89\u5168\u6027\u7684\u5b9e\u7528\u6307\u5357 \u5728\u670d\u52a1\u5668\u7ba1\u7406\u4e2d\uff0c\u66f4\u6539 SSH \u7aef\u53e3\u662f\u4e00\u79cd\u5e38\u89c1\u4e14\u6709\u6548\u7684\u5b89\u5168\u63aa\u65bd\u3002\u901a\u8fc7\u5c06\u9ed8\u8ba4\u7684 SSH \u7aef\u53e3\uff0822\uff09\u66f4\u6539\u4e3a\u4e00\u4e2a\u4e0d\u5e38\u7528\u7684\u7aef\u53e3\uff0c\u53ef\u4ee5\u51cf\u5c11\u6f5c\u5728\u7684\u5b89\u5168\u98ce\u9669\uff0c\u56e0\u4e3a\u653b\u51fb\u8005\u901a\u5e38\u4f1a\u9996\u5148\u5c1d\u8bd5\u9ed8\u8ba4\u7aef\u53e3\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u8be6&#8230;<\/p>\n","protected":false},"author":1,"featured_media":2161,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[62,8,91],"topic":[],"class_list":["post-2160","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-haiwai","tag-ssh","tag-8","tag-91"],"_links":{"self":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts\/2160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/comments?post=2160"}],"version-history":[{"count":1,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts\/2160\/revisions"}],"predecessor-version":[{"id":2163,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/posts\/2160\/revisions\/2163"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/media\/2161"}],"wp:attachment":[{"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/media?parent=2160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/categories?post=2160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/tags?post=2160"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hgfwq.com\/blog\/wp-json\/wp\/v2\/topic?post=2160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}