How to Change the SSH Port for Security?
SSH (Secure Shell) is one of the most common protocols for remote server management. It provides a secure connection to a remote machine and transfers data over an encrypted channel. However, the standard SSH port (port 22) is often the target of attackers. Therefore, changing the SSH port to a different number can enhance the security of your server. In this article, we will look in detail at how to do this.
Step 1: Logging into the Server via SSH
First, let’s open a terminal and connect to the server via SSH. Use the command:
ssh username@server_ip_address
Step 2: Editing the SSH Configuration File
Now that you have connected to the server, edit the SSH configuration file. To do this, execute the command:
sudo nano /etc/ssh/sshd_config
Find the line with the port number (usually Port 22) and replace it with the desired port (for example, Port 2222).
Step 3: Restarting the SSH Service
After making changes to the SSH configuration file, save and close it. Then restart the SSH service to apply the changes. Execute the commands:
sudo systemctl restart sshd
Now the SSH port has been successfully changed to the new number.
Conclusion
Changing the SSH port can increase the security of your server and reduce the likelihood of unauthorized access. Remember that after changing the port, you will need to use the new port number when connecting to the server via SSH.
Follow the instructions above and protect your server from potential threats!