How to Change SSH Port on Linux VPS
IntroductionIn order to properly secure your VPS, you may want to change the default SSH port. Note that, after you begin using a non-default port, every connection to the default port will be rejected which will increasing the chance your VPS has to reject common SSH scanners used by hackers. In this tutorial we will teach you what has to be changed in the VPS configuration so you are able to use a custom SSH port.
PrerequisitesFor this tutorial you are going to require the following: – SSH root access to the VPS
Changing the portOpen the ‘configuration’ file of the SSH daemon by running the command below. nano /etc/ssh/sshd_config You could also use the vim editor, which is installed by default on every linux distribution.
vim /etc/ssh/sshd_configLook for the line below:
# Port 22
Replace it with any port you would like and delete the ‘%’ at the start. Then, save the changed file with CTRL+X or CMD+X if you are using MAC.
For this to take effect, you will have to restart the SSH daemon using the command below.
service sshd restartEverything should now be set, you have just changed your default SSH port. Be sure to remember that, from now on, you are going to be able to access the server using only the port that you have specified in the configuration.
ConclusionCongratulations, you now know how to change the SSH port and highly increase the security of your server.
Updated on 05 Mar 2018
Add a comment