Как да се промени по подразбиране порт 22 на сървъра, SSH на Fedora 26

Промяна на основен потребител


Edit the configuration file for the SSH server

nano /etc/ssh/sshd_config

Make the changes below to the fileAmendments are in amber. Here we have removed the # and specified a number for the port.

# 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 2222
#AddressFamily any
#ListenAddress ::

Запазете файла.

The port specified in the configuration file needs to be enabled in SELinux else you will get an error when restarting the SSH server service.

semanage port -a -t ssh_port_t -p tcp 2222

Restart the SSH server

service sshd restart

Други полезни команди

Install semanage command

dnf -y install policycoreutils-python


If you are using a firewall you may also need to open the port

firewall-cmd --permanent --zone=public --add-port=2222/tcp

firewall-cmd --reload

Вашият коментар