Centos 修改SSH端口报错:error: Bind to port 27615 on 0.0.0.0 failed: Permission denied.
报错截图
问题原因
selinux问题
解决办法
修改selinux中的sshd的端口
# 安装修改工具
$ yum -y install policycoreutils-python
# 查看selinux中的sshd的端口,输出为 22
$ semanage port -l | grep ssh
# 新增端口
$ semanage port -a -t ssh_port_t -p tcp 27615
$ systemctl status sshd
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2022-10-29 10:10:08 CST; 36min ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 8653 (sshd)
CGroup: /system.slice/sshd.service
└─8653 /usr/sbin/sshd -D
Oct 29 10:10:08 centos-linux.shared systemd[1]: Starting OpenSSH server daemon...
Oct 29 10:10:08 centos-linux.shared sshd[8653]: Server listening on 0.0.0.0 port 27615.
Oct 29 10:10:08 centos-linux.shared systemd[1]: Started OpenSSH server daemon.
Oct 29 10:31:44 centos-linux.shared sshd[18735]: Accepted password for root from 10.211.55.2 port 50375 ssh2