修改SSH服务默认的端口22之后,启动sshd服务发现无法启动

 

 该问题原因:selinux

# 安装管理工具

yum install -y policycoreutils-python

# 查看当前ssh端口

semanage port -l | grep ssh

从这里可以看出ssh端口22,并没有我们修改后的自定义端口

# 添加我们自定义的端口

semanage port -a -t ssh_port_t -p tcp 1022

# 防火墙端口放行

firewall-cmd --zone=public --add-port=1022/tcp --permanent
firewall-cmd --reload

 

# 帮助信息

semanage --help
usage: semanage [-h]
                
                {import,export,login,user,port,ibpkey,ibendport,interface,module,node,fcontext,boolean,permissive,dontaudit}
                ...

semanage is used to configure certain elements of SELinux policy with-out
requiring modification to or recompilation from policy source.

positional arguments:
  {import,export,login,user,port,ibpkey,ibendport,interface,module,node,fcontext,boolean,permissive,dontaudit}
    import              Import local customizations
    export              Output local customizations
    login               Manage login mappings between linux users and SELinux
                        confined users
    user                Manage SELinux confined users (Roles and levels for an
                        SELinux user)
    port                Manage network port type definitions
    ibpkey              Manage infiniband ibpkey type definitions
    ibendport           Manage infiniband end port type definitions
    interface           Manage network interface type definitions
    module              Manage SELinux policy modules
    node                Manage network node type definitions
    fcontext            Manage file context mapping definitions
    boolean             Manage booleans to selectively enable functionality
    permissive          Manage process type enforcement mode
    dontaudit           Disable/Enable dontaudit rules in policy

optional arguments:
  -h, --help            show this help message and exit

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐