How to Change SSH Port on Linux VPS Server

how to change ssh port on linux vps server

Have you ever attempted basic port scanning services using Netcat, Nmap, and Telnet on your local network or server? If yes, you’ll know how simple it is to find open ports and the associated services. Anyone can use the search feature to locate port numbers within the cPanel.

Social engineering is used increasingly for advanced cyberattacks that can bypass security measures. However, many cyber-attacks are still scripts written by automated software that mostly target systems with typical configuration errors and insecure default settings.

It’s the standard SSH port that is open by default. Changing your server’s SSH port can shield you from lesser sophisticated attacks. In this guide, we’ll go over how to change the SSH port number in Linux VPS server.


What Is an SSH Port?

Each communication made via ssh will require ports to be connected to begin the connection. No matter if the device is wireless or wired, the device will have ports. There are over 65k ports for communication available, and you are able to start communications with any one port. The default ssh port communications are made using port number 22. However, you can simply change the ssh port number to any accessible port. If the user uses the command to initiate communication between two devices connected to the network, it will use port number 22, which is the default ssh port.

However, if you’re performing any critical communications that require security, it is recommended to change the ssh port number, which is assigned automatically by default to another to prevent attacks using brute force. When you buy Linux VPS hosting, everyone knows the default ssh port number is 22 and is the most vulnerable to hacker attacks. Any hacker could easily steal the data you transfer.

SSH, also known as Secure Shell, is a network protocol utilized to allow remote access to the server. It offers you the security to be able to work with devices on any type of network that is unsecured. This isn’t just about security features but is also a reference to the collection of tools that help make use of an SSH protocol.


Features of SSH Protocol

There are many features that come with SSH.

  •     SSH has secure password authentication, encrypted data transmission, and public-key authentication
  •     It’s used to manage remote systems and applications and allows other users to access the device remotely and carry out different tasks
  •     It is a network protocol that uses cryptographic encryption and utilizes the client/server model
  •     It is possible to create secure tunnels to various application protocols as well. Applications protocols can also be utilized to simulate terminals or to transfer files
  •     Port forwarding


What Is the Default SSH Port Number?

As we’ve mentioned above, when you buy Linux VPS hosting, all communications will be carried out by employing the default SSH port number, which is 22. The port is believed to be insecure for carrying important data since it is widely known that the default port number is 22. It is highly recommended to change the ssh port on Linux VPS to an alternative port to avoid brute-force attacks.


Why Change the Default SSH Port?

As mentioned above, since the default ssh port is very common, it could make you a target for hackers. Hackers frequently look for open ports that allow them to access and steal sensitive data. It is highly recommended by any cyber-security expert to change the ssh port number and add an extra level of security once you buy Linux VPS hosting.


How to Change the SSH Port?

The standard SSH port on the majority of servers is 22. After you gain administrative access to your server, primarily Linux, change the ssh port for security reasons. Be aware that in order for this to happen, you’ll need permission to root.

To change ssh port number:

  •     Step 1. Use SSH to connect to your server, and then log in as root.
ssh {user-name}@{ec2-server-name}


  •     Step 2. Open the sshd_config file with an editor for text. The file is located in the “/etc/ssh” directory.
find / -name “sshd_config” -print
  •     Step 3. Identify the line that says “Port 22” and alter that line with the number of the port that you want to utilize.
  •     Step 4. Save changes when you exit the editor.
  •     Step 5. Restart the SSH service by using the following commands

For CentOS/Fedora:

service sshd restart



For Ubuntu/Debian:

service ssh restart




In this article, we have discussed various functions and features of SSH. With this guide, you’ll be able to change the ssh port on Linux.


Buy Linux VPS Server

Leave a Reply

Your email address will not be published.