Articles on: VPS

Can I Change The Port ssh Listens On?

Yes you can change the port that SSH listens to by editing the /etc/ssh/sshd_config file and uncommenting (Remove the # from the beginning the line) the line containing below.

#Port 22

Example of a changed SSH port

Port 55555

You then can change the number to a uncommon SSH port. Some good examples are 5555 or 33333. You will then have to open that port on in the APF configuration file located at /etc/apf/conf.apf.

You will want to add this new port number to the lines below.


Warning: Remember to place a # right in front of the word Common below

Common ingress (inbound) TCP ports
IG_TCP_CPORTS="20,21,22,25,53,80,110,143,443,465,993,995,2082,2083,2084,2086,2087,2095,2096,6666,55555,7786"


and


Common egress (outbound) TCP ports
EG_TCP_CPORTS="21,25,80,443,43,55555"


After saving the conf.apf file you will need to restart both APF and sshd by issuing the command below on the command line.

/etc/init.d/apf restart && /etc/init.d/sshd restart

Updated on: 07/01/2023

Was this article helpful?

Share your feedback

Cancel

Thank you!