If you have a firewall set up on the server, you will need to ensure that you adjust your firewall settings to allow for connections on the new SSH port. If you have CSF installed (cPanel servers):
Open the CSF config file: nano /etc/csf/csf.conf.
Look for the allowed TCP ports (approximately line 138).
Use the arrow keys to navigate the cursor after one of the separating commas.
Type in your new port number here and add a comma if there are any values after this.
Press Ctrl+X (Command+X on Mac) to quit.
Then, press Y to confirm your changes.
Press the Enter key to confirm that the filename remains the same (do not change this).
Restart CSF using the following command: csf -r.
If you’re using FirewallD (CentOS 7/8, Ubuntu 18+): Note: In this example, the new SSH port is 2222. Make sure you adjust the port number for your use case. Please replace port=2222 with your new nominated port. sudo firewall-cmd --permanent --zone=public --add-port=2222/tcp sudo firewall-cmd --reload