How to Change SSH Port | Step-by-step Guide (2024)

How to Change SSH Port | Step-by-step Guide (1)

In today’s digital age, securing server access is more crucial than ever. One effective method to thwart potential attackers is by altering the default SSH port. This article provides a comprehensive guide on how to safely make this change, ensuring not only a fortified security stance but also uninterrupted server access.

About the SSH Port

SSH (Secure Shell) is a protocol used primarily for secure remote server access and management. When we talk about the “SSH port,” we’re referring to the network port number on which an SSH server listens for incoming connections. By default, SSH servers listen on port 22. However, for security reasons, many system administrators choose to change this default port to another, less predictable number to help protect against automated attacks. Though it’s not mean that this is enough for comprehensive security, additional measures.

Changing the SSH Port

Changing the default SSH port on a Linux system can add an additional layer of security against automated attacks. Here’s a step-by-step guide to help you make the change:

1. Backup the Configuration File. Before making any changes, it’s always a good practice to back up your SSH configuration file.

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.backup

2. Edit the SSH Configuration File. Open the SSHD configuration file with your preferred text editor. For this example, we’ll use nano.

sudo nano /etc/ssh/sshd_config

Sample Output:

How to Change SSH Port | Step-by-step Guide (2)

3. Locate the Port Directive. Find the line that starts with Port. It should say Port 22 by default.

4. Change the Port Number. Edit the line to reflect your desired port number, preferably above 1024 to avoid conflicts with other standard services. For instance, to change it to port 2222, the line would look like:

Port 2222

5. Save and Close the File. If you’re using nano, press CTRL + O to write the changes, then press Enter, and CTRL + X to exit.

6. Adjust Firewall Rules. If you have a firewall enabled (like UFW or Firewalld), you’ll need to update its rules to allow connections on the new SSH port.

sudo ufw allow 2222/tcp

7. Restart the SSH Service. Apply the changes by restarting the SSH daemon.

sudo systemctl restart sshd

8. Test the New SSH Port. Before logging out of your current session, open a new terminal or SSH client and try connecting to the server using the new port to ensure everything works correctly:

ssh username@your_server_ip -p 2222

If you’re sure about your changes and the new port is working, and if you have a firewall enabled, consider closing the default port (22) to enhance security. Always be cautious when changing SSH settings, especially if you’re connecting remotely. Mistakes might lock you out of your server. Once you’re done, your Linux server will now accept SSH connections on the new port, enhancing its security against potential threats targeting the default port.

Conclusion

Looking to deploy Linux in the cloud? With Gcore Cloud, you can choose from Basic VM, Virtual Instances, or VPS/VDS suitable for Linux:

Choose an instance

How to Change SSH Port | Step-by-step Guide (2024)
Top Articles
How Many of These Traits of "The Millionaire Next Door" Do You Share?
What to Do When You Receive a Collection Letter
Craigslist Houses For Rent In Denver Colorado
Methstreams Boxing Stream
Research Tome Neltharus
Atvs For Sale By Owner Craigslist
Seething Storm 5E
Dr Lisa Jones Dvm Married
Miles City Montana Craigslist
Words From Cactusi
Mail Healthcare Uiowa
Oriellys St James Mn
Miami Valley Hospital Central Scheduling
Oro probablemente a duna Playa e nomber Oranjestad un 200 aña pasa, pero Playa su historia ta bay hopi mas aña atras
Radio Aleluya Dialogo Pastoral
Find Such That The Following Matrix Is Singular.
Kürtçe Doğum Günü Sözleri
Lazarillo De Tormes Summary and Study Guide | SuperSummary
Missouri Highway Patrol Crash
St. Petersburg, FL - Bombay. Meet Malia a Pet for Adoption - AdoptaPet.com
Georgia Cash 3 Midday-Lottery Results & Winning Numbers
Why do rebates take so long to process?
Homeaccess.stopandshop
All Breed Database
Yugen Manga Jinx Cap 19
پنل کاربری سایت همسریابی هلو
Gma' Deals & Steals Today
Waters Funeral Home Vandalia Obituaries
Marlene2295
Why comparing against exchange rates from Google is wrong
Indiana Jones 5 Showtimes Near Jamaica Multiplex Cinemas
The Menu Showtimes Near Amc Classic Pekin 14
Family Fare Ad Allendale Mi
Philadelphia Inquirer Obituaries This Week
Latest Nigerian Music (Next 2020)
Cranston Sewer Tax
Encompass.myisolved
My Locker Ausd
Best Restaurants Minocqua
Craigs List Hartford
Emily Tosta Butt
Frontier Internet Outage Davenport Fl
The Largest Banks - ​​How to Transfer Money With Only Card Number and CVV (2024)
Lesson 5 Homework 4.5 Answer Key
18 Seriously Good Camping Meals (healthy, easy, minimal prep! )
Deshuesadero El Pulpo
Diablo Spawns Blox Fruits
De Donde Es El Area +63
Best brow shaping and sculpting specialists near me in Toronto | Fresha
Duffield Regional Jail Mugshots 2023
Latest Posts
Article information

Author: Stevie Stamm

Last Updated:

Views: 6431

Rating: 5 / 5 (80 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Stevie Stamm

Birthday: 1996-06-22

Address: Apt. 419 4200 Sipes Estate, East Delmerview, WY 05617

Phone: +342332224300

Job: Future Advertising Analyst

Hobby: Leather crafting, Puzzles, Leather crafting, scrapbook, Urban exploration, Cabaret, Skateboarding

Introduction: My name is Stevie Stamm, I am a colorful, sparkling, splendid, vast, open, hilarious, tender person who loves writing and wants to share my knowledge and understanding with you.