how to change SSH port number

Step by step procedure with commands.

Thu Mar 18, 2021

How to change SSH port number on Linux machines.

On Linux OS:
ssh as root user
sudo su
Then run this command (use nano or vi editors)

nano /etc/ssh/sshd_config file
then search for "Port 22" and change the port number to the custom port you want.
Save the changes
Restart the SSH service
command:
service sshd restart
or
service ssh restart
Please make sure firewall rules are allowed on the new port number.
Note : Dont close the terminal. Just try to ssh to the device from another terminal using the new port number. if it is working, you are good to close the terminal. Else edit the settings once again and save, then restart the ssh service.