How to Change SSH Port on VPS


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

Reasons to Change Your SSH Port

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.

How to Change SSH Port?

The process is really simple.

Connect to your remote server by performing these steps:

  • 1.Run the following command in your terminal
ssh (username)@(IP address)

Replace the (username) with your account user name, and (IP address) with your VPS IP address. For instance:

ssh username@

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.

2. Input your password and click Enter.

Once you’ve established the connection, follow these steps to configure a new port number:

  • Access the SSH daemon (sshd) by executing this command on your text editor. We’ll be using the vim command in this example.
vim /etc/ssh/sshd_config
  • Find the line that says #Port 22 and change it to your desired port. If you’re using vim, you need to press i to enter insert mode. Only then can you delete the old port and change it. After that hit esq to exit insert mode. Type wq to save your changes and quit.

ProTip! Use port higher than 1024 as those are reserved for commonly known programs on the internet to avoid conflicts.

Set up your new port number below the old one by removing the hashtag and typing in the new desired number, for instance:


After changing the port, you need to restart SSH daemon using this command:

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

please leave a comment lt’s very important for us


Please enter your comment!
Please enter your name here