Linux has high security and stability, and is very suitable for domestic or overseas server operating systems. After we open the server, we usually need the server IP address, port and account information to log in to manage the server. For the sake of security, the default port is often modified first. Let's take a look at the steps to modify the default remote port of the server

Edit sshd_ Config file, add port 123. Port 22 is not deleted here to avoid forgetting to add firewall exceptions, which may cause the host unable to connect.

vi /etc/ssh/sshd_ config

Uncomment Port22 and add a new line Port22

Add Firewall Exception

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

firewall-cmd --reload

Or turn off the firewall

Centos off:

Systemctl stop firewall

Systemctl start firewall

Debian system:

Ufw enable//Enable

Ufw disable//Close

Ubuntu off:

Sudo ufw enable

Sudo ufw disable

Restart service

systemctl restart sshd

Test adding 123 port connections. After normal operation, you can delete sshd_ Port22 in config file

Was this answer helpful? 0 Users Found This Useful (0 Votes)