Modifying SSH connection ports

Posted:  May 14th, 2016

 

Follow this procedure to change your SSH port:

 

    > Login to your server with SSH as root.

 

    > Edit the file /etc/ssh/sshd_config using your favourite text editor.

 

    > Find the line "Port 22" and change 22 to the desired port number (The default ssh port is 22).

 

    > Remove the "#" sign at the beginning of the line (if exist).

 

The part of the file will look like this:

 

    Port 22

 

    > Save the file and exit.

 

    > Restart the sshd service:

 

CentOS

 

    /etc/init.sshd restart

 

Debian

 

    /etc/init.ssh restart

 

Freebsd

 

    /etc/rc.d/sshd stop ; /etc/rc.dsshd start