Làm thế nào để thay đổi cổng mặc định 22 trên máy chủ SSH trên Fedora 26
Thay đổi để người dùng root
của anh ấy
Edit the configuration file for the SSH server
nano /etc/ssh/sshd_config
Make the changes below to the file… Amendments 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 0.0.0.0 #ListenAddress ::
Lưu các tập tin.
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
lệnh hữu ích khác
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
