Since the default SSH port is 22, it can pose a security risk. If you want to change it, first log in to your server via SSH, then:
use the following command to open the file containing the SSH settings.
Inside this file, you’ll find a line specifying the port, as shown in the image below.
Change the line #Port 22 to any number you prefer and will remember, then press CTRL + X to save the changes.
Example: Port 5789
After that, restart the SSHD server.
Code:
nano /etc/ssh/sshd_config
use the following command to open the file containing the SSH settings.
Inside this file, you’ll find a line specifying the port, as shown in the image below.
Change the line #Port 22 to any number you prefer and will remember, then press CTRL + X to save the changes.
Example: Port 5789
After that, restart the SSHD server.
Code:
/etc/init.d/sshd restart