Loading date…
LinkedIn Twitter Instagram YouTube WhatsApp

How to Change SSH Server Default Port on Windows (Step-by-Step Secure Method 2026)

Read full practical guide on How to Change SSH Server Default Port Number on Windows System (Step-by-Step Guide 2026)

How to Change SSH Server Default Port Number on Windows System (Step-by-Step Guide 2026)

In today’s cybersecurity landscape, leaving your SSH server running on the default port is like leaving your front door unlocked in a crowded city. Attackers constantly scan networks for open port 22, targeting systems with weak configurations. If you are running an SSH server on a Windows system, changing the default port is one of the simplest yet effective hardening techniques you can implement.

This guide is written from a cybersecurity expert’s perspective, designed to help beginners and professionals alike securely change the SSH default port on Windows systems. Whether you are managing a personal server, enterprise infrastructure, or a cybersecurity lab, this step-by-step guide will help you implement the change safely without breaking your SSH access.

Table of Contents

What is SSH and Why It Matters?

Read full practical guide on What is SSH and Why It Matters?

Secure Shell (SSH) is a cryptographic network protocol used to securely access remote systems over an unsecured network. It is widely used by system administrators, developers, and cybersecurity professionals for remote server management, file transfers, and secure communication.

On Windows systems, SSH functionality is provided through OpenSSH Server, which is now built into modern Windows versions such as Windows 10 and Windows Server editions. This makes it easier than ever to enable secure remote access without relying on third-party tools.

However, default configurations are often predictable, and attackers exploit this predictability to launch brute-force attacks.

Why Change the Default SSH Port?

Read full practical guide on Why Change the Default SSH Port?

By default, SSH runs on port 22. This is widely known, and automated bots constantly scan for systems listening on this port. Changing the port does not make your system completely secure, but it significantly reduces noise from automated attacks.

Here are the key reasons to change your SSH port:

  • Reduce automated brute-force attacks
  • Minimize log clutter from malicious login attempts
  • Add an extra layer of obscurity to your server
  • Improve baseline security posture

In cybersecurity, this technique is often referred to as "security through obscurity." While not sufficient alone, it is a valuable part of a layered defense strategy.

Prerequisites Before You Start

Read full practical guide on Prerequisites Before You Start SSH Custom Port

Before making any changes, ensure you have the following:

  • Administrator access to your Windows system
  • OpenSSH Server installed and running
  • Basic understanding of command line or PowerShell
  • Backup of your SSH configuration file

To check if SSH server is installed, run the following command in PowerShell:

Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH.Server*'

Locate SSH Configuration File

Read full practical guide on Locate SSH Configuration File

The SSH server configuration file on Windows is located at:

C:\ProgramData\ssh\sshd_config

This file contains all the settings that control how your SSH server behaves. You will need to edit this file to change the default port.

Open Notepad as Administrator and load this file carefully. Avoid using non-admin editors, as they will not allow you to save changes.

How to Change SSH Port on Windows?

Read full practical guide on How to Change SSH Port on Windows?

Follow these steps carefully to change the SSH port:

Step 1: Open sshd_config File

Open the configuration file using Notepad or any text editor with administrative privileges.

Step 2: Locate the Port Setting

Find the following line:

#Port 22

This line is commented out, meaning the default port 22 is being used.

Step 3: Modify the Port

Remove the comment and change the port number:

Port 2222

You can choose any unused port between 1024 and 65535. Avoid commonly used ports such as 80, 443, or 21.

Step 4: Save the File

After making the changes, save the file and close the editor.

Configure Windows Firewall

Read full practical guide on SSH Custom Port Configure Windows Firewall

Changing the SSH port is not enough. You must allow the new port through the Windows Firewall, or your connection will fail.

Run the following command in PowerShell as Administrator:

New-NetFirewallRule -Name "SSH-Port-2222" -DisplayName "SSH Port 2222" -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 2222

This command creates a new inbound rule to allow traffic on port 2222.

Restart SSH Service

Read full practical guide on Restart SSH Service

After updating the configuration and firewall settings, restart the SSH service to apply changes:

Restart-Service sshd

If the service fails to restart, check the configuration file for syntax errors.

Test the New SSH Port

Read full practical guide on Test the New SSH Port

Now test your SSH connection using the new port:

ssh username@your-ip -p 2222

Ensure the connection works before closing your current session. This prevents accidental lockout.

Advanced Security Tips

Read full practical guide on Advanced Security Tips for SSH

Changing the SSH port is just the beginning. For a truly secure setup, implement the following:

  • Disable password authentication and use SSH keys
  • Restrict login to specific users
  • Enable logging and monitoring
  • Use intrusion detection systems
  • Limit SSH access by IP address

Combining these measures creates a strong defense against unauthorized access.

Common Errors and Fixes

Read full practical guide on Common Errors and Fixes for SSH

Connection Refused

This usually means the firewall is blocking the port or SSH service is not running.

Permission Denied

Check user credentials or SSH key configuration.

Service Fails to Restart

Verify the sshd_config file for syntax errors.

Port Already in Use

Choose a different port and update the configuration accordingly.

Frequently Asked Questions

Is changing the SSH port enough for security?

No. It reduces automated attacks but should be combined with other security practices.

Which port should I choose?

Any unused port between 1024 and 65535 is acceptable. Avoid well-known ports.

Can I revert back to port 22?

Yes. Simply update the configuration file and restart the SSH service.

Does changing the port affect performance?

No. It has no impact on performance.

Is this method safe for production servers?

Yes, as long as firewall rules and configurations are correctly applied.

Conclusion

Changing the default SSH port on a Windows system is a simple yet powerful step toward improving your server’s security. While it does not replace strong authentication methods or firewall configurations, it significantly reduces exposure to automated attacks.

As a cybersecurity professional, always think in layers. Security is not about a single setting but a combination of best practices working together. Implement this change today, and take the first step toward a more secure Windows environment.

If you found this guide helpful, consider implementing additional hardening techniques to further protect your systems.

Shubham Chaudhary

Welcome to Xpert4Cyber! I’m a passionate Cyber Security Expert and Ethical Hacker dedicated to empowering individuals, students, and professionals through practical knowledge in cybersecurity, ethical hacking, and digital forensics. With years of hands-on experience in penetration testing, malware analysis, threat hunting, and incident response, I created this platform to simplify complex cyber concepts and make security education accessible. Xpert4Cyber is built on the belief that cyber awareness and technical skills are key to protecting today’s digital world. Whether you’re exploring vulnerability assessments, learning mobile or computer forensics, working on bug bounty challenges, or just starting your cyber journey, this blog provides insights, tools, projects, and guidance. From secure coding to cyber law, from Linux hardening to cloud and IoT security, we cover everything real, relevant, and research-backed. Join the mission to defend, educate, and inspire in cyberspace.

Post a Comment

Previous Post Next Post
×

🤖 Welcome to Xpert4Cyber

Xpert4Cyber shares cybersecurity tutorials, ethical hacking guides, tools, and projects for learners and professionals to explore and grow in the field of cyber defense.

🔒 Join Our Cybersecurity Community on WhatsApp

Get exclusive alerts, tools, and guides from Xpert4Cyber.

Join Now