Changing SSH Port on a Linux VPS: A Beginner's Guide
Changing the default SSH port from 22 to a custom port is a recommended security measure for your server. This tutorial outlines simple steps for various Linux distributions to change your server's SSH port.
Steps for CentOS 6, CentOS 7, Debian 8, Debian 9, Ubuntu 14.04, Ubuntu 16.04, and Ubuntu 18.04:
Log in to Your Linux VPS:
- Use SSH to log in as the root user. You can use a terminal or an SSH client like PuTTY.
Open the SSH Configuration File:
- Run the command:
vi /etc/ssh/sshd_config
Modify the SSH Port:
- Locate the line:
# Port 22
- Remove the
#
symbol and change 22
to your desired port number.
Save and Exit the File:
- Press
Esc
, then type :wq
and press Enter
.
Restart the SSH Service:
You can now connect to your server via SSH using the new port number.
Steps for Fedora 28:
Log in to Your Linux VPS:
Open the SSH Configuration File:
- Run the command:
vi /etc/ssh/sshd_config
Modify the SSH Port:
- Locate the line:
# Port 22
- Remove the
#
symbol and change 22
to your desired port number.
Save and Exit the File:
- Press
Esc
, then type :wq
and press Enter
.
Update the Firewall Rules:
Reload the Firewall and Restart the SSH Service:
Now, you can connect to your Fedora server via SSH using the new port number.
If you encounter any issues or have questions, feel free to leave a comment or contact our 24/7 customer service. We're here to help!