In need to secure your server you should avoid default port for SSH as it will increase the security level and decrease risk of vulnerability. We all know that default SSH port is 22, we should change it to something else but you should must take care before choosing a number that it is not in use by a different service. If you are unsure then you can check the list on Wikipedia.
Before proceeding we should learn where does SSH port can be located and changed ? You can change SSH port in /etc/ssh/sshd_config file.

Now to change SSH port we have to follow these steps :

Step 1). First we have to login to server through SSH as root.

SSH root@hoststud
Step 2). Once we have logged into server we can begin editing /etc/ssh/sshd_config file. But, before editing it we must take backup of this file as it is very important server file. So to take backup we have to run this command.

# cp /etc/ssh/sshd_config /etc/ssh/sshd_config_backup
Step 3). Now we are ready to edit the /etc/ssh/sshd_config file. We will use vim editor to make changes in the file.

# vim /etc/ssh/sshd_config file
Step 4). We will able to see the file opened with the vim editor. If sshd_config file has not been altered before then the Port setting will be commented out with a # symbol. The # symbol tells server to ignore anything written after this on the same line. We have to remove this # symbol and change the port number to as per our need.

Step 5). Now save the changes and close the file. Restart the sshd service to apply the changes we have made.

# restart service sshd

Step 6). After making changes in sshd_config file for SSH port we have to add this port number to CSF firewall on server too.

Step 7). Once again before editing csf.conf file we should take backup of it.

# cp /etc/csf/csf.conf /etc/csf/csf.conf.bak

Step 8). To edit the csf.conf file we will use vim editor.

# vim /etc/csf/csf.conf

Step 9). Now we have to make changes in TCP ports (Incoming/Outgoing).

# Allow incoming TCP ports
TCP_IN = "20,21,22,25,53,80,110,143,443,465,587,993,995,26"
# Allow outgoing TCP ports
TCP_OUT = "20,21,22,25,37,43,53,80,110,113,443,587,873"
Step 10). Save the changes and restart csf to make changes apply.

# restart service csf
or
# csf -r
Author
bhawanisingh
Views
2,495
First release
Last update
Rating
0.00 star(s) 0 ratings
Top