1. Introduction
By default, SSH listens on port 22. Changing it to a custom port can help reduce unauthorized login attempts and automated attacks.
2. Accessing Your VPS via SSH
Connect to your VPS with the current SSH port:
ssh root@your-vps-ip -p 22
3. Steps to Change the SSH Port (Linux)
1. Open the SSH configuration file:
nano /etc/ssh/sshd_config
2. Find the line:
#Port 22
3.Remove the # and replace 22 with your desired port (e.g., 2222):
Port 2222
3. Save the file and exit (CTRL+O, ENTER, CTRL+X).
4. Restart the SSH service:
systemctl restart sshd
5. Update your firewall rules to allow the new port:
ufw allow 2222/tcp ufw reload
4. Important Notes
• Keep your session open when testing the new port to avoid being locked out.
• Avoid using reserved ports (below 1024).
• Update any automation or monitoring tools with the new port.
• You can always reset the port from the MyHBD Cloud Panel by using the console access if locked out.
Was this helpful?
Help others find useful content by rating this guide
Your feedback helps improve our content and SEO ranking