{"id":96,"date":"2024-08-25T19:00:20","date_gmt":"2024-08-25T11:00:20","guid":{"rendered":"https:\/\/518958.xyz\/?p=96"},"modified":"2024-08-25T19:00:20","modified_gmt":"2024-08-25T11:00:20","slug":"centos%e4%bf%ae%e6%94%b9ssh%e7%ab%af%e5%8f%a3%e5%8f%b7","status":"publish","type":"post","link":"https:\/\/518958.xyz\/?p=96","title":{"rendered":"Centos\u4fee\u6539SSH\u7aef\u53e3\u53f7"},"content":{"rendered":"<p>\u8981\u4fee\u6539CentOS\u4e0a\u7684SSH\u7aef\u53e3\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u64cd\u4f5c\uff1a<\/p>\n<p>\u4ee5root\u7528\u6237\u8eab\u4efd\u767b\u5f55CentOS\u7cfb\u7edf\u3002<br \/>\n\u6253\u5f00SSH\u914d\u7f6e\u6587\u4ef6\/etc\/ssh\/sshd_config<\/p>\n<p><code>sudo vi \/etc\/ssh\/sshd_config<\/code><\/p>\n<p>\u5728\u6587\u4ef6\u4e2d\u627e\u5230\u5e76\u4fee\u6539#Port 22\u8fd9\u4e00\u884c\uff0c\u53bb\u6389\u6ce8\u91ca\u7b26\u53f7#\u5e76\u4fee\u6539\u4e3a\u6240\u9700\u7684\u7aef\u53e3\u53f7<\/p>\n<p><code>Port 2222<\/code><\/p>\n<p>\u6ce8\u610f\uff1a\u786e\u4fdd\u6240\u9009\u7aef\u53e3\u53f7\u6ca1\u6709\u88ab\u5176\u4ed6\u5e94\u7528\u7a0b\u5e8f\u5360\u7528\u3002<br \/>\n\u4fdd\u5b58\u5e76\u5173\u95ed\u6587\u4ef6\u3002<br \/>\n\u91cd\u542fSSH\u670d\u52a1\u4ee5\u4f7f\u4fee\u6539\u751f\u6548<\/p>\n<p><code>sudo systemctl restart sshd<\/code><\/p>\n<p>\u786e\u4fdd\u9632\u706b\u5899\u5141\u8bb8\u65b0\u7684SSH\u7aef\u53e3\u901a\u8fc7<\/p>\n<p><code>sudo firewall-cmd --permanent --add-port=2222\/tcp<\/code><br \/>\n<code>sudo firewall-cmd --reload<\/code><\/p>\n<p>\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662fiptables\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4<\/p>\n<p><code>sudo iptables -A INPUT -p tcp --dport 2222 -j ACCEPT<\/code><br \/>\n<code>sudo service iptables save<\/code><br \/>\n<code>sudo service iptables restart<\/code><\/p>\n<p>\u6ce8\u610f\uff1a\u8bf7\u6839\u636e\u60a8\u5b9e\u9645\u4f7f\u7528\u7684\u9632\u706b\u5899\u8f6f\u4ef6\u8fdb\u884c\u76f8\u5e94\u7684\u914d\u7f6e\u3002<br \/>\n\u786e\u4fdd\u60a8\u7684\u8def\u7531\u5668\u6216\u9632\u706b\u5899\u5c06\u65b0\u7684SSH\u7aef\u53e3\u8f6c\u53d1\u5230CentOS\u670d\u52a1\u5668\u7684IP\u5730\u5740\u3002<br \/>\n\u73b0\u5728\uff0c\u60a8\u7684CentOS\u7cfb\u7edf\u7684SSH\u7aef\u53e3\u5df2\u7ecf\u4fee\u6539\u4e3a\u65b0\u7684\u7aef\u53e3\u53f7\u3002\u4f7f\u7528SSH\u5ba2\u6237\u7aef\u65f6\uff0c\u8bf7\u786e\u4fdd\u6307\u5b9a\u4fee\u6539\u540e\u7684\u7aef\u53e3\u53f7<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8981\u4fee\u6539CentOS\u4e0a\u7684SSH\u7aef\u53e3\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u64cd\u4f5c\uff1a \u4ee5root\u7528\u6237\u8eab\u4efd\u767b\u5f55CentOS\u7cfb\u7edf\u3002 \u6253\u5f00SSH\u914d\u7f6e\u6587\u4ef6\/etc\/ssh\/sshd_config sudo vi \/etc\/ssh\/sshd_config \u5728\u6587\u4ef6\u4e2d\u627e\u5230\u5e76\u4fee\u6539#Port 22\u8fd9\u4e00\u884c\uff0c\u53bb\u6389\u6ce8\u91ca\u7b26\u53f7#\u5e76\u4fee\u6539\u4e3a\u6240\u9700\u7684\u7aef\u53e3\u53f7 Port 2222 \u6ce8\u610f\uff1a\u786e\u4fdd\u6240\u9009\u7aef\u53e3\u53f7\u6ca1\u6709\u88ab\u5176\u4ed6\u5e94\u7528\u7a0b\u5e8f\u5360\u7528\u3002 \u4fdd\u5b58\u5e76\u5173\u95ed\u6587\u4ef6\u3002 \u91cd\u542fSSH\u670d\u52a1\u4ee5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":97,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[8],"tags":[],"class_list":["post-96","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-operation"],"_links":{"self":[{"href":"https:\/\/518958.xyz\/index.php?rest_route=\/wp\/v2\/posts\/96","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/518958.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/518958.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/518958.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/518958.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=96"}],"version-history":[{"count":1,"href":"https:\/\/518958.xyz\/index.php?rest_route=\/wp\/v2\/posts\/96\/revisions"}],"predecessor-version":[{"id":98,"href":"https:\/\/518958.xyz\/index.php?rest_route=\/wp\/v2\/posts\/96\/revisions\/98"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/518958.xyz\/index.php?rest_route=\/wp\/v2\/media\/97"}],"wp:attachment":[{"href":"https:\/\/518958.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=96"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/518958.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=96"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/518958.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=96"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}