{"id":652133,"date":"2025-08-12T11:15:59","date_gmt":"2025-08-12T03:15:59","guid":{"rendered":"http:\/\/puo.cn\/?p=652133"},"modified":"2025-08-12T11:15:59","modified_gmt":"2025-08-12T03:15:59","slug":"%e6%94%b9%e5%8f%98%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%ab%af%e5%8f%a322","status":"publish","type":"post","link":"http:\/\/puo.cn\/?p=652133","title":{"rendered":"\u6539\u53d8\u670d\u52a1\u5668\u7aef\u53e322"},"content":{"rendered":"<p>\u5c06SSH\u7aef\u53e3\u4ece\u9ed8\u8ba4\u768422\u6539\u4e3a\u5176\u4ed6\u7aef\u53e3\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u5b89\u5168\u63aa\u65bd\uff0c\u53ef\u4ee5\u6709\u6548\u51cf\u5c11\u81ea\u52a8\u5316\u626b\u63cf\u548c\u66b4\u529b\u7834\u89e3\u653b\u51fb\u3002\u8fd9\u4e2a\u64cd\u4f5c\u4e0d\u4f1a\u5f71\u54cd\u7f51\u7ad9\u8bbf\u5ba2\u7684\u4f7f\u7528\uff0c\u56e0\u4e3aSSH\u662f\u7528\u4e8e\u670d\u52a1\u5668\u7ba1\u7406\u7684\uff0c\u4e0e\u666e\u901a\u7528\u6237\u8bbf\u95ee\u7f51\u7ad9\u768480(HTTP)\u6216443(HTTPS)\u7aef\u53e3\u65e0\u5173\u3002<br \/>\n\u4ee5\u4e0b\u662f\u4fee\u6539SSH\u7aef\u53e3\u5e76\u6700\u5c0f\u5316\u98ce\u9669\u7684\u64cd\u4f5c\u6b65\u9aa4\uff1a<br \/>\n\u5907\u4efdSSH\u914d\u7f6e\u6587\u4ef6<br \/>\nsudo cp \/etc\/ssh\/sshd_config \/etc\/ssh\/sshd_config.bak<br \/>\n\u7f16\u8f91SSH\u914d\u7f6e\u6587\u4ef6<br \/>\nsudo nano \/etc\/ssh\/sshd_config<br \/>\n\u4fee\u6539\u7aef\u53e3\u53f7<br \/>\n\u627e\u5230#Port 22\u8fd9\u4e00\u884c\uff0c\u53bb\u6389\u6ce8\u91ca\u7b26\u53f7#\u5e76\u5c0622\u6539\u4e3a\u4f60\u60f3\u8981\u7684\u65b0\u7aef\u53e3\u53f7\uff08\u5efa\u8bae\u9009\u62e91024-65535\u4e4b\u95f4\u7684\u7aef\u53e3\uff0c\u907f\u514d\u4f7f\u7528\u5e38\u89c1\u670d\u52a1\u7aef\u53e3\uff09<br \/>\nPort 2222<br \/>\n\u4fdd\u5b58\u5e76\u9000\u51fa\u7f16\u8f91\u5668<br \/>\n\u66f4\u65b0\u9632\u706b\u5899\u89c4\u5219<br \/>\n\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662ffirewalld\uff1asudo firewall-cmd &#8211;permanent &#8211;add-port=2222\/tcp<br \/>\nsudo firewall-cmd &#8211;reload<br \/>\n\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662fufw\uff1asudo ufw allow 2222\/tcp<br \/>\nsudo ufw reload<br \/>\n\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662fiptables\uff1asudo iptables -A INPUT -p tcp &#8211;dport 2222 -j ACCEPT<br \/>\nsudo iptables-save &gt; \/etc\/iptables\/rules.v4<br \/>\n\u5728\u963f\u91cc\u4e91\u63a7\u5236\u53f0\u6dfb\u52a0\u5b89\u5168\u7ec4\u89c4\u5219<br \/>\n\u767b\u5f55\u963f\u91cc\u4e91\u63a7\u5236\u53f0\uff0c\u627e\u5230\u4f60\u7684\u670d\u52a1\u5668\u5b9e\u4f8b\uff0c\u5728\u5b89\u5168\u7ec4\u914d\u7f6e\u4e2d\u6dfb\u52a0\u65b0\u7684\u5165\u7ad9\u89c4\u5219\uff0c\u5141\u8bb8\u4f60\u9009\u62e9\u7684\u65b0\u7aef\u53e3(\u59822222)\u7684TCP\u8bbf\u95ee\u3002<br \/>\n\u91cd\u542fSSH\u670d\u52a1<br \/>\nsudo systemctl restart sshd<br \/>\n\u6d4b\u8bd5\u65b0\u7aef\u53e3\u8fde\u63a5<br \/>\n\u5728\u4e0d\u5173\u95ed\u5f53\u524dSSH\u8fde\u63a5\u7684\u60c5\u51b5\u4e0b\uff0c\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\u7a97\u53e3\uff0c\u5c1d\u8bd5\u4f7f\u7528\u65b0\u7aef\u53e3\u8fde\u63a5\uff1a<br \/>\nssh -p 2222 username@your_server_ip<br \/>\n\u786e\u8ba4\u8fde\u63a5\u6210\u529f\u540e\uff0c\u518d\u5173\u95ed\u539f\u6765\u7684\u8fde\u63a5\u3002<br \/>\n\u989d\u5916\u5b89\u5168\u5efa\u8bae\uff1a<br \/>\n\u4f7f\u7528\u5f3a\u5bc6\u7801\u6216SSH\u5bc6\u94a5\u8ba4\u8bc1<br \/>\n\u7981\u7528root\u7528\u6237\u767b\u5f55\uff0c\u4f7f\u7528\u666e\u901a\u7528\u6237+sudo<br \/>\n\u5b89\u88c5fail2ban\u7b49\u5de5\u5177\u9632\u6b62\u66b4\u529b\u7834\u89e3<br \/>\n\u5b9a\u671f\u66f4\u65b0SSH\u670d\u52a1<br \/>\n\u8003\u8651\u4f7f\u7528VPN\u6216\u8df3\u677f\u673a\uff0c\u53ea\u5141\u8bb8\u5185\u7f51IP\u8bbf\u95eeSSH\u7aef\u53e3<br \/>\n\u5b8c\u6210\u8fd9\u4e9b\u6b65\u9aa4\u540e\uff0c\u4f60\u7684SSH\u670d\u52a1\u5c06\u5728\u65b0\u7aef\u53e3\u4e0a\u8fd0\u884c\uff0c\u5927\u5927\u964d\u4f4e\u4e86\u88ab\u81ea\u52a8\u5316\u653b\u51fb\u7684\u98ce\u9669\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c06SSH\u7aef\u53e3\u4ece\u9ed8\u8ba4\u768422\u6539\u4e3a\u5176\u4ed6\u7aef\u53e3\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u5b89\u5168\u63aa\u65bd\uff0c\u53ef\u4ee5\u6709\u6548\u51cf\u5c11\u81ea\u52a8\u5316\u626b\u63cf\u548c\u66b4\u529b\u7834\u89e3\u653b\u51fb\u3002\u8fd9\u4e2a\u64cd\u4f5c\u4e0d\u4f1a\u5f71\u54cd\u7f51\u7ad9\u8bbf\u5ba2\u7684\u4f7f\u7528\uff0c\u56e0\u4e3aSSH\u662f\u7528\u4e8e\u670d\u52a1\u5668\u7ba1\u7406\u7684\uff0c\u4e0e\u666e\u901a\u7528\u6237\u8bbf\u95ee\u7f51\u7ad9\u768480(HTTP)\u6216443(HTTPS)\u7aef\u53e3\u65e0\u5173\u3002 \u4ee5\u4e0b\u662f\u4fee\u6539S&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[128],"tags":[242,444],"topic":[],"class_list":["post-652133","post","type-post","status-publish","format-standard","hentry","category-128","tag-242","tag-444"],"_links":{"self":[{"href":"http:\/\/puo.cn\/index.php?rest_route=\/wp\/v2\/posts\/652133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/puo.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/puo.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/puo.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/puo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=652133"}],"version-history":[{"count":1,"href":"http:\/\/puo.cn\/index.php?rest_route=\/wp\/v2\/posts\/652133\/revisions"}],"predecessor-version":[{"id":652134,"href":"http:\/\/puo.cn\/index.php?rest_route=\/wp\/v2\/posts\/652133\/revisions\/652134"}],"wp:attachment":[{"href":"http:\/\/puo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=652133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/puo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=652133"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/puo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=652133"},{"taxonomy":"topic","embeddable":true,"href":"http:\/\/puo.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftopic&post=652133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}