How to Change the SSH Port on a VPS?
SSH (Secure Shell) is a cryptographic network protocol that is widely used to provide secure data transmission between remote computers. It uses a secure connection to transmit data, as well as to manage remote devices. The default SSH port is 22. However, for security purposes, it is sometimes recommended to change the SSH port on a VPS.
Changing the SSH port on a VPS is an excellent practice to enhance server security. Attackers can scan servers for vulnerabilities, and changing the SSH port will help reduce the likelihood of unauthorized access to the server. In this article, we will tell you how to change the SSH port on a VPS.
Step 1: Connecting to the Server
First of all, you need to connect to your server via SSH. To do this, enter the following command in the terminal:
ssh username@your_server_ip
Where username is your username on the server, and your_server_ip is the IP address of your server.
Step 2: Editing the SSH Configuration File
Now let’s edit the SSH configuration file. To do this, enter the following command in the terminal:
sudo nano /etc/ssh/sshd_config
This command will open the SSH configuration file in the Nano text editor. Find the line #Port 22 and uncomment it by removing the # character. Then change the port to the desired value (for example, 2222):
Port 2222
After making changes, save and close the file by pressing Ctrl+X, then confirm the changes by pressing Y.
Step 3: Restarting the SSH Service
In order for the changes to take effect, restart the SSH service. Enter the following command in the terminal:
sudo systemctl restart sshd
Now the SSH port on your VPS has been successfully changed. Please remember that after changing the port, you should use the new port to connect to the server. Be careful and keep your data safe!
We hope this article was helpful to you. Good luck managing your server!