Skip to content
  • Solutions
    By Role
    • For Developers
    • For Content Managers
    • For Agencies
    • For IT Admins
    • For Web Hosters
    • For Developers
    • For Content Managers
    • For Agencies
    • For IT Admins
    • For Web Hosters
    By Infrastructure
    • Overview
    • AWS
    • Microsoft Azure
    • Alibaba Cloud
    • Google Cloud Platform
    • Vultr
    • Overview
    • AWS
    • Microsoft Azure
    • Alibaba Cloud
    • Google Cloud Platform
    • Vultr
    • Digital Ocean
    • Linode
    • Upcloud
    • Oracle
    • OVH
    • Digital Ocean
    • Linode
    • Upcloud
    • Oracle
    • OVH
  • Product
    • Plesk Features
    • Plesk Editions
    • What’s new
    • Pricing
    • Roadmap
    • Lifecycle Policy
    • Extensions Catalogue
  • Pricing
  • Extensions
    Featured Extensions
    • SocialBee
    • WP Toolkit
    • Sitejet Builder for Plesk
    • SEO Toolkit
    • Joomla! Toolkit
    • Premium Email
    • Email Security
    • SocialBee
    • WP Toolkit
    • Sitejet Builder for Plesk
    • SEO Toolkit
    • Joomla! Toolkit
    • Premium Email
    • Email Security
    Bundles and packs:
    • Business and Collaboration Edition
    • WP pack
    • Hosting pack
    • Power pack
    • Language pack
    • Business and Collaboration Edition
    • WP pack
    • Hosting pack
    • Power pack
    • Language pack

    See all Extensions

  • For Partners
    • Plesk Contributor Program
    • Plesk Partner Program
    • Affiliate program
    • Plesk University
  • Help Center
    • Documentation
    • Professional Services
    • Support
    • Contact Us
    • Wiki
    • Forum
  • Plesk 360 login
  • Free Trial
  • Pricing
  • Solutions
    • By Role
      • For Developers
      • For Content Managers
      • For Agencies
      • For IT Admins
      • For Web Hosters
    • By Infrastructure
      • Overview
      • Plesk on Amazon Web Services (AWS & Lightsail)
      • Microsoft Azure
      • Alibaba Cloud
      • Google Cloud Platform
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
      • Oracle
      • OVH
  • Products
  • Pricing
  • Extensions
    • Featured Extensions
      • SocialBee
      • WP Toolkit
      • Sitejet Builder for Plesk
      • SEO Toolkit
      • Joomla! Toolkit
      • Premium Email
      • Email Security
    • Bundles and packs:
      • Business and Collaboration Edition
      • WP pack
      • Hosting pack
      • Power pack
      • Language pack
      • See all Extensions
  • For Partners
    • Plesk Contributor Program
    • Plesk Partner Program
    • Affiliate Program
    • Plesk University
  • Help Center
    • Documentation
    • Professional Services
    • Support
    • Contact Us
    • Wiki
    • Forum
  • Plesk 360 login
  • Free Trial
  • Pricing
  • Solutions
    • By Role
      • For Developers
      • For Content Managers
      • For Agencies
      • For IT Admins
      • For Web Hosters
    • By Infrastructure
      • Overview
      • Plesk on Amazon Web Services (AWS & Lightsail)
      • Microsoft Azure
      • Alibaba Cloud
      • Google Cloud Platform
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
      • Oracle
      • OVH
  • Products
  • Pricing
  • Extensions
    • Featured Extensions
      • SocialBee
      • WP Toolkit
      • Sitejet Builder for Plesk
      • SEO Toolkit
      • Joomla! Toolkit
      • Premium Email
      • Email Security
    • Bundles and packs:
      • Business and Collaboration Edition
      • WP pack
      • Hosting pack
      • Power pack
      • Language pack
      • See all Extensions
  • For Partners
    • Plesk Contributor Program
    • Plesk Partner Program
    • Affiliate Program
    • Plesk University
  • Help Center
    • Documentation
    • Professional Services
    • Support
    • Contact Us
    • Wiki
    • Forum
  • Plesk 360 login
  • Free Trial
Plesk 360 login
Free Trial

Knowledge Base

How to change the SSH port number on a Linux server

 
fail2banfirewallgoiplinux

Question

How to change the SSH port number on a Linux server?

Answer

  1. Connect to the server via SSH.

  2. Open the SSH configuration file /etc/ssh/sshd_config in any text editor. In this example we are using the vi editor:

    # vi /etc/ssh/sshd_config

  3. Modify the file according to your needs using one of these steps:

    Warning: Be careful when modifying the file. The incorrect SSH configuration may lead to server inaccessibility via SSH.

    • Set up one custom SSH port

      Remove the hash "#" in the line #Port 22 and specify your custom SSH port, which will be used instead of standard SSH port 22.
      Example:

      Port 2222

    • Set up several SSH ports

      Remove the hash "#" in the line #Port 22 and additionally add your custom SSH port on the next line. In this case, SSH connections will be available on both ports.
      Example:

      Port 22
      Port 2222

  4. Save the changes and close the file.

  5. Restart the sshd service to apply the changes:

    # service sshd restart

    Note: The new port must be opened in server firewall. Visit this KB article to find out how.

    Note: If port is changed on a SELinux system, it is needed to tell SELinux about this change:
    # semanage port -a -t ssh_port_t -p tcp #PORTNUMBER

 

Additional step if the Fail2Ban ssh jail is enabled on the server

 

If the Fail2Ban ssh jail is enabled on the server, modify its configuration to meet new changes:

  1. Log in to Plesk.

  2. Go to Tools & Settings > IP Address Banning (Fail2Ban) > switch to the Jails tab and click ssh.

    Screenshot_2019-01-10_IP_Address_Banning_-_Plesk_Onyx_17_8_11.png

  3. On the ssh page, click Change Settings and change the port value from ssh to your new custom SSH port (In this example, it is 2222). Once done, apply the changes.

    Note: If the default port (22) and custom port are used, add them as "port=2222".

    Screenshot_2019-01-10_ssh_-_Plesk_Onyx_17_8_11.png

 

Tweet
Share
Share
Email
0 Shares
Read the full article
Related Posts

How to Check Open Ports in Linux (Simple Commands & Tools)

Read More »

Linux Logs Explained

Read More »

How to Host a Go App on Plesk

Read More »
Knowledge Base

How to redirect webmail of all domains to a specific webmail URL in Plesk for Linux

Read More »

How to whitelist IP addresses for ModSecurity in Plesk?

Read More »

 How to configure the passive ports range for ProFTPd on a Plesk server behind a firewall

Read More »

New components can not be installed on a Plesk Obsidian server with the EOLed OSes: repository ‘http://autoinstall.plesk.com/pool/PSA_18.0.34_5691 xenial Release’ does not have a Release file

Read More »

Hosting Wiki

  • Django
  • RESTful Web Service
  • Server Redundancy
  • Cloud Service Architecture
  • Virtualizor
  • On-Demand Services
  • Linux Containers
  • Google Cloud CDN
  • Bare Metal Server
  • Denial of Service
  • Red Hat Virtualization
  • Virtuozzo
  • Oracle VM Server
  • Citrix Hypervisor
  • Server Virtualization Software
  • Windows Server
  • Linux
  • Virtualization
  • JavaScript
  • MongoDB
  • VirtualMin
  • Plesk
  • Web Server
  • DNS Server
  • IPv6
  • IPv4
  • SIP
  • SSH
  • UDP/IP
  • Firewall
  • Email Virus Protection
  • TCP/IP
X-twitter Linkedin Youtube Reddit Github
  • Product
  • Login
  • Pricing
  • Editions
  • For Partners
  • Partner Program
  • Contributor Program
  • Affiliate Program
  • Plesk University
  • Company
  • Blog
  • Careers
  • Events
  • About Plesk
  • Our Brand
  • Resources
  • User and Admin guides
  • Help Center
  • Migrate to Plesk
  • Contact Us
  • Hosting Wiki
  • Forum
  • Legal
  • Legal
  • Privacy Policy
  • Imprint

© 2025 WebPros International GmbH

Part of the WebPros®  Family