NewExtra server protection with Measured Boot & UKI images.View Measured Boot
BlogDocumentationFAQNo Third-Party CookiesContact Us
  • Pricing
Log inSign up
Cloud VPSVDSMemory-Optimized VDSStorage-Optimized VDSWindows VPSBitcoin VPSDDoS ProtectionPrivate Networking (VPC)Floating IPsAdditional Server SupportMicrosoft LicensesDatacenterNetworkDocumentationFAQNo Third-Party CookiesConfidential ComputingSelf-Hosted VPNBlogAboutBrand GuidelinesAffiliatesContact UsLegal & Compliance

Products

  • Pricing
  • Cloud VPS
  • VDS
  • RAM-Optimized VDS
  • Storage-Optimized VDS
  • Windows VPS
  • Bitcoin VPS
  • DDoS Protection
  • Private Networking (VPC)
  • Floating IPs
  • Microsoft Licenses
  • Additional Server Support

Explore

  • Documentation
  • Developers API Docs
  • FAQ
  • Datacenter
  • Network
  • Looking Glass
  • Confidential Computing
  • Cookie Policy
  • Self-Hosted VPN

Company

  • Blog
  • Contact Us
  • About Us
  • Brand Guidelines
  • Affiliates

Legal & Compliance

  • Terms of Service
  • Privacy Policy
  • Data Processing Agreement
  • Acceptable Use Policy
  • Microsoft Software Terms of Use
  • Refund Policy
  • Report Abuse

Products

  • Cloud VPS
  • VDS
  • RAM-Optimized VDS
  • Storage-Optimized VDS
  • Windows VPS
  • Bitcoin VPS
  • DDoS Protection
  • Private Networking (VPC)
  • Floating IPs
  • Microsoft Licenses
  • Additional Server Support
Pricing

Explore

  • Documentation
  • Developers API Docs
  • FAQ
  • Datacenter
  • Network
  • Looking Glass
  • Confidential Computing
  • Cookie Policy
  • Self-Hosted VPN

Company

  • Blog
  • Contact Us
  • About Us
  • Brand Guidelines
  • Affiliates

Legal & Compliance

  • Terms of Service
  • Privacy Policy
  • Data Processing Agreement
  • Acceptable Use Policy
  • Microsoft Software Terms of Use
  • Refund Policy
  • Report Abuse

© VPS.BG Ltd. 2026 · All rights reserved!

Made with passion in Bulgaria · VAT ID: BG203144520

Contents

  • Log in through SSH
  • How to change the SSH port
  • Restart the SSH service

Subscribe to Our Newsletter

Join 5000+ subscribers and receive helpful content, deals and more! We promise no spam - 100% great content. Unsubscribe anytime.

Share Article

#Security
  1. Documentation
  2. /
  3. #Security
  4. /
  5. How to change your SSH port

How to change your SSH port

Published: 03 February 2020 • 2 min read

#Tutorial#Security

When it comes to changing the SSH port, it is just one of the steps that you need to undertake in order to ensure better security for your server(s). By default the port is set to 22 and not changing these default settings could result in your server being susceptible to online attacks.

Changing the default settings is easy and in this tutorial we are going to show you how to change your port in just a few steps!

Log in through SSH

Firstly, you will need to have access to your server. Because of this, you are going to need to log in through SSH. Simply open up your preferred SSH client or type the following command into your terminal:

ssh root@your_server_ip

IMPORTANT: You need to replace ‘your_server_ip’ with your server’s IP address!

If you are not familiar with SSH, you can follow our detailed tutorial on how to create a SSH key.

How to change the SSH port

Once you have successfully logged into your server, you will need to change the ‘/etc/ssh/sshd_config’ file.

IMPORTANT: Make sure to make a backup of this file before making any changes! To make a copy of the file use this command:

cp /etc/ssh/sshd_config /etc/ssh/sshd_config_

Once you have made a copy of the file, open the config with your preferred editor. For this tutorial, we are going to be using ‘vim’. The command to run vim is:

vim /etc/ssh/sshd_config

You should now see a screen similar to this:

changing the SSH port

You should immediately be able to identify the line that corresponds to the SSH port - Port 22.

If this line commented out (has a # sign before Port 22), you will need to remove the #. Next, to edit the file, press ‘i’. This will switch the system into editing mode. You can now edit the file and change the SSH port to something like 22002 or another port that you like.

IMPORTANT: Don’t set the port to another one which is already in use!

Finally, press the [ESC] button and type ‘:x’ to save and exit vim.

Restart the SSH service

In order for your changes to be applied, you will need to restart the sshd service. You can do so with this command:

service sshd reload

IMPORTANT: Make sure to check whether your server has a firewall installed! If it does, check the rules and make sure to add your new SSH port to the firewall configuration settings. If you don’t, you will not be able to connect to your server via SSH!

You can also use the following command to check the syntax:

sshd -t

If you experience any problems while changing your SSH port, feel free to contact our technical support team!

Subscribe to Our Newsletter

Join 5000+ subscribers and receive helpful content, deals and more! We promise no spam - 100% great content. Unsubscribe anytime.

Share Article

Related Content

19 July 2023

How to install Windows on a cloud server

In this tutorial, we are going to show you how to install Windows OS on your cloud server from an ISO file with Windows Server 2022 & VirtuIO drivers.

#Tutorial#Windows
15 January 2023

How to set up Laravel Forge on your VPS server

Learn how to install Laravel Forge on your VPS or VDS and start managing your Linux server. Deploy PHP applications and databases with ease.

#Tutorial#Laravel
01 April 2025

How to perform AMD SEV-SNP attestation inside a guest virtual machine

In this tutorial, we are going to show you how to perform AMD SEV-SNP attestation inside a guest virtual machine to verify trust and security.

#Tutorial#SEV
02 February 2026

QEMU Guest Agent (QGA) Troubleshooting Guide

A detailed step-by-step guide on how to troubleshoot QEMU guest agent issues for Ubuntu, Debian, Rocky, Alma, Fedora and Windows Server.

#Tutorial#QGA

Unrivaled Performance & Security

Deploy a powerful and reliable Cloud VPS today to ensure your privacy. SEV-SNP included for maximum protection.

Configure VPSContact Us