The Gcore Customer Portal is being updated. Screenshots may not show the current version.
Technical supportAPIBecome a resellerReferral program
Chosen image
Home/Hosting/Virtual Servers/Manage/Connect/Linux server/Change port for SSH connections

Change the port for SSH connections

Follow these instructions to modify the SSH port through which you connect to your Linux server.

  1. Log in to your server.

  2. Navigate to the SSH directory using the following command:

cd /etc/ssh/
  1. Open the SSH configuration file with root privileges using this command:
sudo nano sshd_config
  1. Find the Port line in the open file and replace the value 22 with the port number you want to use. Also, remove the # symbol if it is present before the Port line.
terminal terminal
  1. Press Ctrl+O to save the changes.

  2. Restart the SSH service. For Ubuntu, Debian, or CentOS, use the following command:

sudo systemctl restart ssh

For FreeBSD, use:

sudo service sshd restart
  1. Add a rule to permit traffic exchange on the new port using the command:
sudo ufw allow 2233

Replace “2233” with the chosen port.

  1. Verify if everything is functioning properly by using the command:
telnet 2233

Replace “” with your server IP address, and “2233” with the chosen port.

The output should look like this:

  1. Attempt to establish a connection to your server using the new port in a separate window without closing your current session. This step is crucial to prevent any potential loss of access to your server. If you encounter difficulties connecting to your server through the new port, revert the port back to 22 and then try again.

Was this article helpful?

Not a Gcore user yet?

Enhance your online presence with our virtual and dedicated servers.

Go to the product page