Skip to the content
Cloudfanatic Knowledge baseCloudfanatic Knowledge base
  • Home
  • Log In
  • System Status
  • Home
  • Log In
  • System Status

How can we help?

e.g. ssh keys, set up mysql, ubuntu 22 mysql php nginx, account settings

Account Functions

  • Your Dashboard
  • Accessing your server for the first time
  • Controlling you instance
  • Cloudfanatic Operating systems and Rebuilding your instance
  • DNS Manager
  • Custom ISO images

Sales & Billing

  • Cloudfanatic Crypto Payments
  • Frequently Asked Questions (FAQ)
  • Server billing
  • Automatic billing for your account
  • Server Upgrades
  • Cloudfanatic Affiliate Program
  • Automated Server backups

News & Announcements

  • RockyLinux 9 now generally available for all instances
  • AlmaLinux 9 now generally available for all instances
  • Servercheap is now Cloudfanatic and more news
  • Ubuntu 22 now generally available for all instances
  • Cloudfanatic/Servercheap has been featured on HostAdvice
  • New 1-Click App – CyberPanel
  • New location: North Carolina
  • Cloudfanatic/Servercheap has been featured on Hostingadvice.com
  • Centos Stream now generally available for all instances
  • Cloudfanatic receives an additional new direct IP allocation from ARIN
  • Cloudfanatic is Introducing 1-Click Apps

Tutorials

  • Secure Apache with Let’s Encrypt on Ubuntu 22.04
  • Setup Apache and Virtual Hosts on Ubuntu 22
  • Change SSH Port on Almalinux
  • Change SSH Port on Debian 10/11
  • Change SSH Port on Ubuntu 20/22
  • Firewalld Cheat Sheet
  • Ubuntu UFW Cheat sheet
  • How to copy my files to and from a linux vps
  • Create passwordless login with SSH keys and PUTTY
  • Accessing your server for the first time
  • DNS Manager
  • Controlling you instance
  • Home
  • Docs
  • Tutorials
  • Change SSH Port on Ubuntu 20/22

Change SSH Port on Ubuntu 20/22

Table of Contents
  • Overview
  • Change your ssh port:
  • Check your firewall UFW

Overview #

In this short tutorial you will learn how to change your SSH port from the default 22 to another port. This is a recommended step during any initial server hardening.

Instructions for Debian

Instructions for Almalinux

Change your ssh port: #

  • Edit your ssh configuration file:
nano /etc/ssh/sshd_config
  • Find line: #Port 22
  • Uncomment the line
  • Change 22 to your desired port number
  • Save the file
  • Restart SSH service
systemctl restart ssh

Check your firewall UFW #

ufw status
Status: active

If your firewall is active, it is possible it would be blocking your newly set port. As such add a firewall rule to allow your new port through the firewall:

ufw allow from any to any port 12345
ufw reload

where 12345 is the ssh port you set, or if you have existing firewall rules, it might be a good idea to add your rule on top of all rules to avoid conflicts:

ufw insert 1 allow from any to any port 12345
ufw reload

That should be all. Try and ssh into your server on your new port.

What are your Feelings
Share This Article :
  • Facebook
  • Twitter
  • LinkedIn
  • Pinterest
Still stuck? How can we help?

How can we help?

Updated on November 1, 2022
Change SSH Port on Debian 10/11Firewalld Cheat Sheet

Powered by BetterDocs

Table of Contents
  • Overview
  • Change your ssh port:
  • Check your firewall UFW

2023 Cloudfanatic Knowledge base

To the top ↑ Up ↑