CentOS8添加自定义SSH端口失败处理方法

本文介绍了解决CentOS8系统中SELinux自定义SSH端口失效的方法。通过卸载并重装相关组件,确保自定义端口设置生效。

故障原因分析

CentOS8系统安装policycoreutils-python-utils-2.9-16.el8.noarch后,能够通过semanage正常添加自定义ssh端口,随后对系统执行dnf update更新系统后发现原来添加的自定义ssh端口失效,如下

[root@vps ~]# getenforce 
Enforcing
[root@vps ~]# semanage port -l | grep ssh
ssh_port_t                     tcp      22    //仅剩下原默认端口

重新添加出现以下报错信息

[root@vps ~]# semanage port -a -t ssh_port_t -p tcp 44422
libsepol.context_from_record: type kdump_var_lib_t is not defined
libsepol.context_from_record: could not create context structure
libsepol.context_from_string: could not create context structure
libsepol.sepol_context_to_sid: could not convert system_u:object_r:kdump_var_lib_t:s0 to sid
invalid context system_u:object_r:kdump_var_lib_t:s0
libsemanage.semanage_validate_and_compile_fcontexts: setfiles returned error code 255.
OSError: [Errno 0] Error
[root@vps ~]# 

由此可知故障为升级系统导致,通过分析确定解决方法为重装selinux-policy。

故障处理步骤

1.卸载semanage

[root@vps ~]# dnf remove policycoreutils-python-utils-2.9-16.el8.noarch
Repository cr is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository extras-source is listed more than once in the configuration
Repository fasttrack is listed more than once in the configuration
Dependencies resolved.
===========================================================================================================================================
 Package                                   Architecture        Version                                       Repository               Size
===========================================================================================================================================
Removing:
 policycoreutils-python-utils              noarch              2.9-16.el8                                    @BaseOS                 138 k
Removing dependent packages:
 setroubleshoot-plugins                    noarch              3.3.14-1.el8                                  @AppStream              2.6 M
 setroubleshoot-server                     x86_64              3.3.24-4.el8                                  @AppStream              1.3 M
Removing unused dependencies:
 checkpolicy                               x86_64              2.9-1.el8                                     @BaseOS                 1.7 M
 python3-audit                             x86_64              3.0-0.17.20191104git1c2f876.el8               @BaseOS                 325 k
 python3-libsemanage                       x86_64              2.9-6.el8                                     @BaseOS                 438 k
 python3-policycoreutils                   noarch              2.9-16.el8                                    @BaseOS                 5.4 M
 python3-setools                           x86_64              4.3.0-2.el8                                   @BaseOS                 2.6 M

Transaction Summary
===========================================================================================================================================
Remove  8 Packages

Freed space: 14 M
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                   1/1 
  Erasing          : setroubleshoot-plugins-3.3.14-1.el8.noarch                                                                        1/8 
  Erasing          : setroubleshoot-server-3.3.24-4.el8.x86_64                                                                         2/8 
  Running scriptlet: setroubleshoot-server-3.3.24-4.el8.x86_64                                                                         2/8 
  Erasing          : policycoreutils-python-utils-2.9-16.el8.noarch                                 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

肥肠粉打野

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值