You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: support/windows-server/system-management-components/troubleshoot-openssh-windows-firewall-port22.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
2
-
title: Troubleshoot OpenSSH Communication through Windows Firewall
2
+
title: Troubleshoot OpenSSH Communication Through Windows Firewall
3
3
description: Discusses how to troubleshoot issues that affect OpenSSH commands that pass through Windows Firewall.
4
4
ms.date: 12/17/2025
5
5
manager: dcscontentpm
@@ -16,7 +16,7 @@ ms.custom:
16
16
17
17
This article discusses how to troubleshoot issues that affect OpenSSH commands that pass through Windows Firewall.
18
18
19
-
By default, OpenSSH uses TCP port 22. If this port is blocked or not listening, SSH commands fail. By default, OpenSSH listens on both IPv4 (0.0.0.0:22) and IPv6 ([::]:22). Windows Firewall settings, service status, and network permissions all play a crucial role in ensuring that port 22 is both listening and accessible. Many factors can block OpenSSH communication, such as the following issues:
19
+
By default, OpenSSH uses TCP port 22. If this port is blocked or not listening, SSH commands fail. By default, OpenSSH listens on both IPv4 (0.0.0.0:22) and IPv6 ([::]:22). Windows Firewall settings, service status, and network permissions all play a crucial role in making sure that port 22 is both listening and accessible. Many factors can block OpenSSH communication, such as the following issues:
20
20
21
21
- The OpenSSH service isn't running or is misconfigured.
22
22
- Port 22 isn't listening because of service or firewall problems.
@@ -28,7 +28,7 @@ By default, OpenSSH uses TCP port 22. If this port is blocked or not listening,
28
28
29
29
### Step 1: Verify the basic functionality
30
30
31
-
1. To verify that OpenSSH installed correctly, open a Windows PowerShell Command Prompt window and then run the following command:
31
+
1. To verify that OpenSSH installed correctly, open a Windows PowerShell Command Prompt window, and then run the following command:
32
32
33
33
```powershell
34
34
Get-Service -Name sshd
@@ -43,7 +43,7 @@ By default, OpenSSH uses TCP port 22. If this port is blocked or not listening,
43
43
netstat -an | findstr :22
44
44
```
45
45
46
-
The following example shows the response to this command when port 22 is listening for traffic.
46
+
The following example shows the response to this command when port 22 is listening for traffic:
47
47
48
48
```output
49
49
TCP 0.0.0.0:22 0.0.0.0:0 LISTENING
@@ -58,35 +58,35 @@ By default, OpenSSH uses TCP port 22. If this port is blocked or not listening,
58
58
> - Avoid using port 22 for non-OpenSSH traffic.
59
59
> - Audit your firewall rules regularly.
60
60
61
-
1. To check for existing firewall rules, on your OpenSSH client computer, run the following cmdlet at a PowerShell command prompt.
61
+
1. To check for existing firewall rules, go to your OpenSSH client computer, and run the following cmdlet at a PowerShell command prompt:
1. To check that the rule is correctly configured, run `Get-NetFirewallRule` again.
73
+
1. To verify that the rule is correctly configured, run `Get-NetFirewallRule` again.
74
74
75
75
### Step 3: Review the event logs for errors
76
76
77
77
In Event Viewer, review the entries in **Application and Services Logs** > **OpenSSH**.
78
78
79
79
### Step 4: If the port isn't listening, configure it
80
80
81
-
If in the previous steps `netstat` didn't report port 22 as "Listening," and the firewall rule is correctly configured, follow these steps:
81
+
In the previous steps, if`netstat` didn't report port 22 as "Listening," and the firewall rule is correctly configured, follow these steps:
82
82
83
83
1. To check the service status, run the following command at a PowerShell command prompt:
84
84
85
85
```powershell
86
86
Get-Service -Name sshd
87
87
```
88
88
89
-
1. To check the OpenSSH configuration, in the C:\ProgramData\ssh\ folder, use a text editor to open the sshd_config file.
89
+
1. To check the OpenSSH configuration, open the C:\ProgramData\ssh\ folder, and then use a text editor to open the sshd_config file.
90
90
1. Go to the `Port` section of the file. If the port information is commented out, uncomment it, and then make sure that the value is `22`.
91
91
92
92
> [!IMPORTANT]
@@ -98,26 +98,26 @@ If in the previous steps `netstat` didn't report port 22 as "Listening," and the
98
98
sshd -t
99
99
```
100
100
101
-
1. To restart the OpenSSH server service, run the following cmdlet at a PowerShell command prompt.
101
+
1. To restart the OpenSSH server service, run the following cmdlet at a PowerShell command prompt:
102
102
103
103
```powershell
104
104
Restart-Service sshd
105
105
```
106
106
107
107
### Step 5: Test for firewall issues
108
108
109
-
1. To create a temporary test rule, run the following cmdlet at a PowerShell command prompt
109
+
1. To create a temporary test rule, run the following cmdlet at a PowerShell command prompt:
110
110
111
111
```powershell
112
112
New-NetFirewallRule -Name "SSH-Test" -DisplayName "SSH Test Rule" -Enabled True -Direction Inbound -Protocol TCP -LocalPort 22 -Action Allow -Profile Any
113
113
```
114
114
115
115
> [!NOTE]
116
-
> This cmdlet creates a temporary rule called "SSH Test Rule" that opens port 22. By using this approach, you avoid having to disable the entire firewall.
116
+
> This cmdlet creates a temporary rule that's named "SSH Test Rule" to open port 22. By using this approach, you avoid having to disable the entire firewall.
117
117
118
118
1. Test some OpenSSH commands. If they work correctly, review and adjust your permanent firewall rules.
119
119
120
-
1. When you're finished, remove the test rule by running the following cmdlet at a PowerShell command prompt.
120
+
1. When you're finished, remove the test rule by running the following cmdlet at a PowerShell command prompt:
121
121
122
122
```powershell
123
123
Remove-NetFirewallRule -Name "SSH-Test"
@@ -145,7 +145,7 @@ If in the previous steps `netstat` didn't report port 22 as "Listening," and the
145
145
146
146
For information about verbose logging for OpenSSH, see [How to enable OpenSSH verbose logging](enable-openssh-verbose-logging.md).
147
147
148
-
Review the logs in %ProgramData%\ssh\logs for information about connection attempts and errors.
148
+
For information about connection attempts and errors, review the logs in %ProgramData%\ssh\logs.
0 commit comments