Change SSH Port
Changing the SSH port of your server is always a good idea to increase security. Basically, every server on the internet will be scanned by bot servers looting for any weakness in your security. If you do not have a firewall on your server, think about installing CSF. It’s a great free firewall that can really help protect your server. If you also use the standard SSH port of 22 then your server will be brute-forced and eventually the password could be compromised.
Change The SSH Port
To get started ensure you have nano installed and let’s edit the sshd_config file;
yum install nano -y nano /etc/ssh/sshd_config
Look for the block of text that looks like this, your text will have a # in front of the lines;
Port 22 AddressFamily any ListenAddress 0.0.0.0 ListenAddress ::
To change specific parameters within sshd_config, you need to uncomment the line by removing the number sign (#) and changing the value for the line. For example, the default ssh port appears in a line like this:
To change the ssh port to 4566, you will need to make the line appear like this:
The file will look like this after the modifications;
Port 4566 AddressFamily any ListenAddress 0.0.0.0 ListenAddress ::
Save the file (cntl +x) keeping the same file name.
Finally, for the new settings to take effect restart the SSHD service;
service sshd restart
After you restart ssh, you will need to log out of your server and log in again using the new port number you specified in the sshd_config file.
IMPORTANT: If you have a firewall deployed to your server remember to close port 22 and open the port you specified above or you won’t be able to connect after you close the console.
How was this article? – How to change the ssh port of your server
More from cPanel
Free SSL Certificates from places like cPanel or Let's Encrypt are great. When Let's Encrypt first introduces free SSL Certificates …
SWAP is a memory type that Linux NVMe VPS Servers use to process requests. Memory will be held in SWAP …
The Error: last request failed: [AUTH] Authentication failed error can be caused by a range of things. It could be …