5

CentOS 8修改ssh默认端口

 6 months ago
source link: https://vpsxb.net/6071/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

CentOS 8修改ssh默认端口

> 网络资源 > CentOS 8修改ssh默认端口
202206191902179.png

1、编辑sshd配置文件,将#Port 22取消注释改成您想修改的端口,如:22345

vi /etc/ssh/sshd_config

2、将新端口添加至防火墙规则

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

3、向SELinux中开放新端口,需要先安装semanage及其依赖包policycoreutils-python-utils:

yum provides semanage 
yum -y install policycoreutils-python-utils

添加开放端口:

semanage port -a -t ssh_port_t -p tcp 22345

4、重启SSHD服务

systemctl restart sshd.service

此时就可以用新端口连接了


VPS小白 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:CentOS 8修改ssh默认端口

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK