October 1, 2019
2min Read
Edgaras G.
Even though Secure Shell (SSH) allows you to have a secure connection with your remote server, changing the standard SSH port number is necessary for the sake of your VPS security. In this article, we’ll be explaining how to change SSH port on your VPS, as well as delving deeper into why you’d want to change the port in the first place.
SSH is a secure network protocol created for communication between devices across the Internet. It enables you to transmit data, commands, and even files. So, you can remotely log in and take control of another device.
To establish remote access, you need to use an SSH client, such as the built-in OpenSSH client in Linux, to connect to your SSH server.
The connection is commonly done via the standard SSH port 22/TCP. Consequently, the port becomes a popular target of brute force attacks – either through SSH key scanning or root account login attempts. Therefore, changing your default VPS port can add an extra layer of security.
The process is really simple.
Connect to your remote server by performing these steps:
ssh (username)@(IP address)
Replace the (username) with your account user name, and (IP address) with your VPS IP address. For instance:
ssh username@189.15.0.7
Note: If this is your first time changing the port or even using SSH, you need to confirm whether or not you’ll continue connecting to a remote device. Type yes to allow the connection.
Once you’ve established the connection, follow these steps to configure a new port number:
vim /etc/ssh/sshd_config
ProTip! Use port higher than 1024 as those are reserved for commonly known programs on the internet to avoid conflicts.
1026
service sshd restart
At this point, make sure that your newly selected port is not blocked. If this is a new VPS server, all ports should be open by default.
As the standard port 22 tends to be an easy target for attackers, it’s recommended to change the default port to add extra protection to your server.
Once you’re connected to your VPS, configure a new port number via the SSH daemon. If you’ve set specific rules to your firewall, please make sure that your desired port is unblocked.
Great, now you’ve learned how to change SSH port!
Leave a reply