How can I change the SSH port for my Linux VPS server?
It’s normal to receive bots attack if you kept your ssh port default 22. We recommend you to change the ssh port to something else. Automatic scrips and bots randomly attack all public IP addresses on all the known ports and try logging into those servers on various brute force methods. So, changing the SSH port will make it hard for those scripts to guess your SSH port and prevent the most common attacks.
To change the SSH port to a non-default port for your Linux Server
Step-1: Connect to your server via SSH as a root user.
Step-2: Run the following command: vi /etc/ssh/sshd_config (or you can use any other text editor you want in place of vi)
Step-3: Locate the following line: # Port 22
Step-4: Remove the # symbol and change 22 to your desired port number.
Step-5: Restart the sshd service by running the following command: service sshd restart
Also, we recommend you to use the CSF firewall (if possible) for better security. Although changing only the SSH port does not guarantee your security, it can absolutely increase the strength of security when combined with other security measures.