Change SSH Port

First, Open SSH Configuration File (sshd) :

sudo nano /etc/ssh/sshd_config

Find the line that reads #Port 22. Next, eplace it with New Port :

To:

Second, Save File Modification Press Ctrl + O and Enter After Press Ctrl + X

Next, restart the SSH service using the following command:

Debian and Ubuntu:

sudo service ssh restart

Debian and Ubuntu with systemd:

sudo systemctl restart ssh

CentOS and Fedora

sudo service sshd restart

CentOS and Fedora with systems:

sudo systemctl restart sshd