Linux系统修改SSH远程端口
Last updated
2023-01-28 10:46:06
{"value":"\u8fd9\u91cc\u4ee5Centos7.6\u7cfb\u7edf\u4e3a\u4f8b\uff0c\u5927\u90e8\u5206Liunx\u7cfb\u7edf\u9002\u7528\u3002\n\n### 1.\u767b\u5f55\u4e91\u670d\u52a1\u5668\n**\u6253\u5f00\u63a7\u5236\u53f0\u6216\u8005\u8fdc\u7a0b\u8fde\u63a5\u60a8\u7684\u4e91\u670d\u52a1\u5668\u3002**\n\n \u5728\u547d\u4ee4\u884c\u8f93\u5165\u5982\u4e0b\u547d\u4ee4\uff0c\u6253\u5f00sshd\u670d\u52a1\u6587\u4ef6\uff0c\n\n [root@CDNCloud ~]# vi \/etc\/ssh\/sshd_config \n\n### 2.\u641c\u7d22\u547d\u4ee4\u884c\n**\u5728\u6587\u4ef6\u4e2d\u627e\u5230\u5982\u4e0b\u547d\u4ee4\u884c\u3002**\n #Port 22\n #AddressFamily any\n #ListenAddress 0.0.0.0\n #ListenAddress ::\n\n\u6309I\u952e\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\uff0c\u628aPort\u884c\u6ce8\u91ca#\u5220\u9664\uff0c\u5e76\u628a\u7aef\u53e3\u53f722\u4fee\u6539\u4e3a\u60a8\u60f3\u8981\u7684\u7aef\u53e3\u53f7\u3002\u8fd9\u91cc\u6211\u4eec\u4fee\u6539\u4e3a33389\u3002\n\n\uff08\u6ce8\uff1a\u5efa\u8bae\u4fee\u6539\u7aef\u53e3\u8303\u56f4\u4e3a1024-65535\uff0cCDNCloud\u5efa\u8bae\u60a8\u4fee\u6539\u4e3a10000\u4ee5\u4e0a\u7aef\u53e3\u53f7\u3002\uff09\n\n Port 33389\n\n\u4fee\u6539\u5b8c\u540e\u6309Esc\u952e\u9000\u51fa\u7f16\u8f91\u6a21\u5f0f\uff0c\u5728\u6309`\uff1a`\u5206\u53f7\u952e\u8fdb\u5165\u672b\u884c\u6a21\u5f0f\u952e\u5165wq\u4fdd\u5b58\u5e76\u9000\u51fa\u3002\n\n \uff1awq\n\n### 3.\u9632\u706b\u5899\u653e\u884c\u8fdc\u7a0b\u7aef\u53e3\n**\u4f9d\u6b21\u8f93\u5165\u5982\u4e0b2\u6761\u547d\u4ee4\uff0c\u653e\u884c33389\u7aef\u53e3\u548c\u91cd\u542f\u9632\u706b\u5899\u670d\u52a1\uff0csuccess\u8868\u793a\u6210\u529f\u3002**\n\n [root@CDNCloud ~]# firewall-cmd --zone=public --add-port=33389\/tcp --permanent\n success\n [root@CDNCloud ~]# firewall-cmd --reload\n success\n\n### 4.\u91cd\u542fSSH\n**\u6700\u540e\u91cd\u542fSSH\u670d\u52a1\u3002**\n [root@CDNCloud ~]# systemctl restart sshd\n\n\u5168\u90e8\u64cd\u4f5c\u5b8c\u6210\u540e\u5c31\u53ef\u4ee5\u8fdb\u884c\u8fdc\u7a0b\u8fde\u63a5\u6d4b\u8bd5\u4e86\uff0c\u8bb0\u5f97\u8fde\u63a5\u7aef\u53e3\u8981\u4fee\u6539\u54e6\uff01\n\n\u5907\u6ce8\uff1a\n\n- CDNCloud\u5e73\u53f0Debian\u548cUbuntu\u7cfb\u7edf\u4e0d\u9700\u8981\u9632\u706b\u5899\u653e\u884c\u7aef\u53e3\n- \u5efa\u8bae\u4fee\u6539\u7aef\u53e3\u53f7\u8303\u56f4\u4e3a1024-65535\uff0cCDNCloud\u5efa\u8bae\u60a8\u4fee\u6539\u4e3a10000\u4ee5\u4e0a\u7aef\u53e3\u53f7\u3002\n- SELinux\u72b6\u6001CDNCloud\u5e73\u53f0\u955c\u50cf\u4e00\u822c\u662fdisabled\uff0c\u5982\u679c\u662fenforcing\uff0c\u5c31\u4f1a\u5bfc\u81f4\u90e8\u5206\u7aef\u53e3\u4fee\u6539\u5b8c\u540e\u91cd\u542fsshd\u62a5\u9519\u3002\n\n\u67e5\u770bSELinux\u72b6\u6001\u547d\u4ee4\uff1agetenforce\u3002\n\n [root@CDNCloud ~]# getenforce\n Disabled\n\n\u5173\u95ed\u547d\u4ee4:\n\n [root@CDNCloud ~]# sed -i s#SELINUX=enforcing#SELINUX=disabled# \/etc\/selinux\/config"}