By default servers will use port 22 for SSH access but it’s highly recommended to change the SSH port to something more random to prevent malicious users from attempting to access your server.
Step 1. Log in to your server via a terminal with an account that has root/sudo privileges.
sudo nano /etc/ssh/sshd_config
Step 3. Find the line “#Port 22” and remove the “#” and then change the number to your desired port.
sudo service sshd restart
Ensure you have tested the new port in a new SSH window before exiting your current session.