It is common to see the default ports are brute-forced attacks entries in your log files. Some of the common ones like part 25, 110 etc. Not limited to port 22, the default port for SSH.
If you have a VPS or a dedicated server, you will have SSH with root access. For convenience, they are delivered with SSH default port 22. However, we encourage the user to change their SSH port from the default 22 to another port, and it is not conflicted with other services.
In today’s example, we use port 1222. Since we have decided to use port 1222, we have to make sure you can connect to port 1222, so we must open up the port 1222 in order to SSH remotely.
For CentOS using firewalld we do this;
- sudo firewall-cmd –permanent –remove-service=ssh
- sudo firewall-cmd –permanent –add-port=1222/tcp
For CentOS using iptables do this;
- iptables -A INPUT -p tcp -m tcp –dport 1222 -j ACCEPT
- Remember to save
Now port 1222 is opened. We can proceed up the SSH port. Edit using vi /etc/ssh/sshd_confug
go to #port 22 press ‘i to update to port 1222 and save it with this command, press ESC mah=ke sure you are loner seeing the word ‘insert’ at the left below screen use this command to save :wq
Now, we reboot the server and all the services will be restarted with the new value. Congratulation! You have changed your SSH port to 1222. Should you face any difficulty with this please contact our support team.