When communicating with other devices, Linux Virtual Private Servers (VPS) make use of a certain collection of connection ports by default. But, if you need to get past port blocking or want to make your VPS more secure, altering the connection port might be useful. In this post, we will walk you through the process of changing the connection port on a Linux virtual private server (VPS) in a step-by-step manner.
Step 1: Connect to the VPS
To change the connection port, you must first connect to the VPS using SSH or any other remote access method.
Step 2: Access the SSH Configuration File
Once you’re connected to the VPS, use the following command to get to the SSH configuration file:
sudo nano /etc/ssh/sshd_config
Step 3: Locate the Port Line
In the configuration file, locate the line that specifies the port number used by SSH. By default, the port number is set to 22.
Step 4: Change the Port Number
To change the port number, replace the default port number with the new port number. Choose a port number between 1024 and 65535 that is not already in use. For example, you can set the port number to 2222.
Step 5: Save the Changes
Once you have changed the port number, save the changes to the configuration file by pressing “Ctrl + X,” then “Y,” and finally “Enter.”
Step 6: Restart the SSH Service
To apply the changes, you must restart the SSH service by running the following command:
sudo systemctl restart sshd
Step 7: Verify the Changes
After restarting the SSH service, connect to the VPS using the new port number to make sure the changes worked. You can do this by specifying the new port number in the remote access client when connecting to the VPS.
Changing the connection port on a Linux VPS can help make it safer and stop ports from being blocked. Changing the connection port on your Linux VPS is easy if you follow the step-by-step instructions in this article. It’s important to remember to restart the SSH service after making changes to ensure that the changes are applied successfully.