当前位置: 首页 > Linux

服务器新增ssh远程端口

时间:2023-04-07 01:39:42 Linux

由于某些情况,22端口没有对外开放,但是为了方便自己...偷偷新开一个ssh远程端口服务器环境操作系统:CentOSLinux7(Core)内核:Linux3.10.0-123。el7.x86_64修改sshd_config配置文件vi/etc/ssh/sshd_config找到Port和ListenAddress的配置区,修改如下Port22Port443#EnablegloballisteningListenAddress0.0.0.0说明:开启22注意防止配置意外,后面的22连不上,可以当做掩护,然后制定443作为备用端口,重启sshd服务systemctlrestartsshd修改防火墙配置/etc/selinux/config如下修改SELINUX=disabled开启端口或关闭防火墙#开启端口firewall-cmd--add-port=10010/tcp--permanent#关闭防火墙systemctlstopfirewalld添加或修改端口类型#如果是新端口,添加-asemanageport-a-tssh_port_t-ptcp443#443是https端口,所以修改semanageport是-m-m-tssh_port_t-ptcp443semanageinstallation如果提示Nopackagesemanageavailable,直接安装yuminstallsemanage。可以使用下面yum提供的方法semanageyum-yinstallpolicycoreutils-python。x86_64测试端口监听正常。网络统计-nap|grepsshd显示如下监控信息,说明配置正常。LISTEN711/sshd用于外网测试sshsshuser@out-ip-p443