Centos Failed to Modify the port of SSH: error: Bind to port 27615 on 0.0.0.0 failed: Permission denied.

Error screenshot

problem causes

selinux problem

Solution

Modify the port of sshd in selinux

# Install the modification tool
$ yum -y install policycoreutils-python

# Check the port of sshd in selinux, the output is 22
$ semanage port -l | grep ssh

# New ports
$ 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

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *