How to Install and Change SSH Port for OpenSSH Server on Windows 10
How to Install and Change SSH Port for OpenSSH Server on Windows 10
Follow these steps to install OpenSSH Server on your Windows 10 machine and change the SSH port to 2222.
1. Install OpenSSH Server on Windows 10
- Open Settings → Apps → Optional Features.
- Scroll down and click Add a feature.
- Find OpenSSH Server in the list and click Install.
If you prefer PowerShell, run:
Add-WindowsCapability -Online -Name OpenSSH.Server
2. Start and Enable OpenSSH Service
Open PowerShell or Command Prompt as Administrator and run:
Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'
3. Allow SSH Port in Windows Firewall
Allow the default SSH port (22):
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
4. Test the SSH Connection
Try connecting from another computer:
ssh your_username@your_windows_ip
5. Change SSH Port to 2222
- Go to
C:\ProgramData\ssh\. - Open the file
sshd_configwith Notepad as Administrator. - Find the line
#Port 22, remove the#, and change22to2222:
Port 2222
Save the file.
6. Open Port 2222 in Windows Firewall
New-NetFirewallRule -Name sshd2222 -DisplayName 'OpenSSH Server (sshd) 2222' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 2222
7. Restart the SSH Service
Restart-Service sshd
8. Connect to the New SSH Port
Now, connect using the new port:
ssh your_username@your_windows_ip -p 2222
Or specify port 2222 in your SSH client (e.g., PuTTY).
If you have any issues during these steps, feel free to ask for help in the comments!