This tutorial will provide you with a few simple steps on
how to change your server's SSH port from default 22 to any other port. This is
highly recommended in order to increase your server security. Please
take note that a new
port number should not be used by any other service or be blocked by your server firewall rules.
Changing SSH Port On CentOS 6, CentOS 7, Debian 8,
Debian 9, Ubuntu 14.04, Ubuntu 16.04, Ubuntu 18.04:
To change SSH port on operating systems mentioned
above, complete the following steps:
1. Login to your Linux VPS via SSH as root user. You can do it via terminal/shell or
use SSH client, for example, PuTTY.
2. Copy the command:
3. Find the line with information:
# Port 22
4. Remove the # symbol and change "22"
into your wanted port number.
5. Save and exit the file (Press
"Esc" then enter :wq).
6. Restart your sshd service by running
command bellow:
For CentOS 6, Debian 8, Debian 9:
For CentOS 7:
systemctl restart sshd.service
For Ubuntu 14.04, Ubuntu 16.04, Ubuntu 18.04:
From now on, you will be able to connect via
SSH using your newly updated port number.
Changing SSH Port On Fedora 28
1. Login to your Linux VPS via SSH.
2. Copy the command:
3. Find the line with information:
# Port 22
4. Remove the # symbol and change
"22" into your wanted port number.
5. Save and exit the file (Press
"Esc" then enter :wq).
6. Create new rule in Fedora's firewall
allowing to connect via SSH using your new port number. Change "22"
to your new port number:
firewall-cmd --permanent --service="ssh" --add-port "22/tcp"
7. Restart the firewall and SSH service:
firewall-cmd --reload; systemctl reload sshd
From now on, you will be able to connect via
SSH, on your Linux VPS, using your newly
updated port number. If you
have any questions, or have trouble completing the provided steps, please leave
us a comment or contact our 24/7 customer service. We will gladly answer any
inquiries you may have.