How to configure SSH Server to listen on multiple ports (2024)

By default, SSH is configured to listen on port 22. However, there may be situations where it is necessary to configure the SSH server to listen on multiple ports. This setup can be beneficial when the server is part of multiple networks that require different ports for SSH connections.

How to configure SSH Server to listen on multiple ports (1)

Configuring SSH to listen on multiple ports involves modifying the sshd_config file. This file allows the administrator to define additional ports on which the server will listen. Proper configuration ensures that the SSH server can handle connections on all specified ports.

It is also important to ensure that your firewall and SELinux policies are updated to permit traffic on these additional ports. Without these adjustments, the server may not be able to accept connections on the newly configured ports.

Steps to run SSH server on multiple ports:

  1. Launch terminal application.

  2. Check if the ports you plan to assign to your SSH service are not already in use.

    $ ss -tlnp | grep -E "22|2022"LISTEN 0 128 *:22 *:*LISTEN 0 128 :::22 :::*

    SSH service currently runs on port 22, which is expected.

  3. Open the sshd configuration file using your preferred text editor.

    $ sudo vi /etc/ssh/sshd_config
  4. Locate the Port directive in the configuration file.

  5. Add each desired port on a new line using the Port directive.

    Port 22Port 2022

    Ensure that each port is listed on a separate line using the Port directive.

    Make sure the line does not begin with # as it implies the line is commented and will be ignored.

  6. Save the changes to the sshd configuration file.

  7. Configure your firewall to allow connections on the newly added ports (optional, if firewall is enabled).

    $ sudo ufw allow 2022/tcp # Ubuntu/Debian$ sudo firewall-cmd --add-port=2022/tcp --permanent && sudo firewall-cmd --reload # CentOS / Red Hatsuccesssuccess

    It is assumed the default port, 22 is already configured with correct firewall configuration. Add if necessary.

  8. Configure selinux to allow SSH to run on the configured port (optional, if selinux is used).

    $ sudo semanage port -a -t ssh_port_t -p tcp 2022

    semanage can be installed on CentOS or Red Hat systems using the following command:

    $ sudo yum install --assumeyes policycoreutils-python

    It is assumed the default port, 22 is already configured with correct selinux policy. Add if necessary.

  9. Restart the sshd service to apply the changes.

    $ sudo systemctl restart sshd
  10. Verify that the sshd service is listening on all configured ports.

    $ ss -tlnp | grep 22LISTEN 0 128 *:2022 *:*LISTEN 0 128 *:22 *:*LISTEN 0 128 :::2022 :::*LISTEN 0 128 :::22 :::*

How to configure SSH Server to listen on multiple ports (2)

How to configure SSH Server to listen on multiple ports (3)

Author: Mohd Shakir Zakaria
Mohd Shakir Zakaria is an experienced cloud architect with a strong development and open-source advocacy background. He boasts multiple certifications in AWS, Red Hat, VMware, ITIL, and Linux, underscoring his expertise in cloud architecture and system administration.

How to configure SSH Server to listen on multiple ports (4) How to configure SSH Server to listen on multiple ports (5)How to configure SSH Server to listen on multiple ports (6) How to configure SSH Server to listen on multiple ports (7)

Discuss the article:

Comment anonymously. Login not required.

How to configure SSH Server to listen on multiple ports (2024)
Top Articles
SIPC - What is SIPC?
The Best Way To Experience Stockholm And Its Cruise Port – Cruise Bulletin
Hotels Near 6491 Peachtree Industrial Blvd
The Largest Banks - ​​How to Transfer Money With Only Card Number and CVV (2024)
Brady Hughes Justified
Occupational therapist
Jesus Calling December 1 2022
Pickswise the Free Sports Handicapping Service 2023
Tribune Seymour
Garrick Joker'' Hastings Sentenced
Top Hat Trailer Wiring Diagram
Craigslist Jobs Phoenix
Thotsbook Com
Trini Sandwich Crossword Clue
Dr. med. Uta Krieg-Oehme - Lesen Sie Erfahrungsberichte und vereinbaren Sie einen Termin
Teenleaks Discord
Brett Cooper Wikifeet
Inside the life of 17-year-old Charli D'Amelio, the most popular TikTok star in the world who now has her own TV show and clothing line
Palm Springs Ca Craigslist
MLB power rankings: Red-hot Chicago Cubs power into September, NL wild-card race
Lista trofeów | Jedi Upadły Zakon / Fallen Order - Star Wars Jedi Fallen Order - poradnik do gry | GRYOnline.pl
Lowes Undermount Kitchen Sinks
Scout Shop Massapequa
Busted Mcpherson Newspaper
Morse Road Bmv Hours
Www.paystubportal.com/7-11 Login
T Mobile Rival Crossword Clue
Elbert County Swap Shop
Shoe Station Store Locator
Criterion Dryer Review
What Sells at Flea Markets: 20 Profitable Items
Unity Webgl Car Tag
Ullu Coupon Code
Keshi with Mac Ayres and Starfall (Rescheduled from 11/1/2024) (POSTPONED) Tickets Thu, Nov 1, 2029 8:00 pm at Pechanga Arena - San Diego in San Diego, CA
Restored Republic
Mia Malkova Bio, Net Worth, Age & More - Magzica
47 Orchid Varieties: Different Types of Orchids (With Pictures)
Serenity Of Lathrop - Manteca Photos
Gwu Apps
Craigslist Georgia Homes For Sale By Owner
Myanswers Com Abc Resources
Pokemon Reborn Locations
Wo ein Pfand ist, ist auch Einweg
This 85-year-old mom co-signed her daughter's student loan years ago. Now she fears the lender may take her house
Mbfs Com Login
Toomics - Die unendliche Welt der Comics online
20 Mr. Miyagi Inspirational Quotes For Wisdom
RubberDucks Front Office
This Doctor Was Vilified After Contracting Ebola. Now He Sees History Repeating Itself With Coronavirus
Ups Customer Center Locations
Craigslist Farm And Garden Missoula
Wayward Carbuncle Location
Latest Posts
Article information

Author: Jerrold Considine

Last Updated:

Views: 6663

Rating: 4.8 / 5 (78 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Jerrold Considine

Birthday: 1993-11-03

Address: Suite 447 3463 Marybelle Circles, New Marlin, AL 20765

Phone: +5816749283868

Job: Sales Executive

Hobby: Air sports, Sand art, Electronics, LARPing, Baseball, Book restoration, Puzzles

Introduction: My name is Jerrold Considine, I am a combative, cheerful, encouraging, happy, enthusiastic, funny, kind person who loves writing and wants to share my knowledge and understanding with you.