文章目錄
- 修改配置檔案
- 防火牆放行
- SELinux添加修改的SSH端口
- 重新開機服務
修改配置檔案
vi /etc/ssh/sshd_config
- 添加2222
# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
Port 22
Port 2222
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
防火牆放行
firewall-cmd --zone=public --add-port=2222/tcp --permanent
firewall-cmd --reload
SELinux添加修改的SSH端口
如果不修改SELinux直接重新開機sshd,會出現
Bind to port 2222 on 0.0.0.0 failed: Permission denied
錯誤
- 安裝管理工具
yum -y install policycoreutils-python
- 新增selinux中sshd的端口
semanage port -a -t ssh_port_t -p tcp 2222
重新開機服務
systemctl restart sshd