编程开源技术交流,分享技术与知识

网站首页 > 开源技术 正文

centos7修改默认ssh端口以及问题排查

wxchong 2024-10-06 04:32:59 开源技术 18 ℃ 0 评论

1、修改ssh端口号的方法

修改:$ sudo vi /etc/ssh/sshd_config

重启:sudo systemctl restart sshd.service

重启后报错

Job for sshd.service failed because the control process exited with error code.See “systemctl status sshd.service” and “journalctl -xe” for details.

3、原因分析

查看SElinux允许的ssh的端口号

$ sudo semanage port -l | grep ssh

发现SELinux允许的ssh的端口号和ssh配置文件中设置的端口号不一致。

4、解决方法

使用semanage工具添加ssh端口号

sudo semanage port -a -t ssh_port_t -p tcp 8888

重启

sudo systemctl restart sshd.service

重启后还是登录不了,解决办法为:

1、关闭firewall:

service firewalld stop

2、添加规则:

firewall-cmd --permanent --add-port=8888/tcp

重启服务

service firewalld restart

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表