How to change default SSH port on Linux
Changing the default SSH port from the default 22 is one of the things you should do to secure your server.
The main benefit of changing the default port is to avoid being scanned by casual port scans.
Changing the default port to a random number get rid of some dangerous brute-force attacks.
Get a .co.ke domain from KSh 299
Search for your business name to see which extensions are available.
First-year price for eligible registrations.
- 500+ domain extensions
- Low registration and renewal prices
- One-click push to Cloudflare
-
Login Via SSH
First you need to log in to your VPS via SSH. If the default port is 22 then you will not need to specify the port.
ssh root@IP_Address
-
Update Packages
For CentOS
yum update -y
For Ubuntu
apt-get update $$ apt-get upgrade
-
Open SSH Config File
Once the packages are updated, open the SSH configuration file with your favourite editor and find the line that specifies the SSH port
vim /etc/ssh/sshd_config
#Port 22
-
Change port number
Uncomment the line by removing the # sign and change the default port 22 to one that you want to use.
Port 9845
Save changes and exit
NB:
Before changing the port, you should make sure that the new port is free and not used by any other service on your VPS.
You should also check that the port is not closed by your server’s firewall
-
Restart SSH Service
For the changes to take effect, the service needs to be restarted
service sshd restart
-
Check SSH port
Once restarted, SSH will listen on port 9845 .
This can be checked by running the following command
netstat -tunlp |grep ssh
Start With This
Best value compares each plan's lowest monthly equivalent; contract lengths can differ.
WebHosting Starter
Kshs 188/mo
Kshs 6,768 billed every 3 yearsSave KES 11,232
Renews at Kshs 188/month
- Hosts 10 Websites
- WordPress Hosting & other CMS
- ~25 000 visits monthly
- Free Website Migrations
- 30 GiB SSD Storage
- 1-click Installer
- Free automated SSL
- Unlimited bandwidth
- Unlimited Email Accounts
- Free Daily backups
- Free Website Builder
- Free Website Templates
- Python and NodeJS Support
- Shared IP Address
- Powered by Cpanel
Explore web hosting
Compare hosting options for your website when you’re ready.
See plans and pricing
Domain SearchInstantly check and register your preferred domain name
Web Hosting
cPanel HostingHosting powered by cPanel (Most user friendly)
WordPress HostingHost your WordPress website with fast, secure, and affordable WordPress hosting in Kenya.
KE Domains
Reseller HostingStart your own hosting business without tech hustles
Windows HostingOptimized for Windows-based applications and sites.
Free Domain
Affiliate ProgramEarn commissions by referring customers to our platforms
Free HostingTest our SSD Hosting for free, for life (1GB storage)
Domain TransferMove your domain to us with zero downtime and full control
All DomainsBrowse and register domain extensions from around the world
.Com Domain
WhoisLook up domain ownership, expiry dates, and registrar information
VPS Hosting
Managed VPSNon techy? Opt for fully managed VPS server
Dedicated ServersEnjoy unmatched power and control with your own physical server.