|
| 1 | +--- |
| 2 | +title: Use "MaxStartups" and "MaxSessions" to Troubleshoot OpenSSH Connection Issues |
| 3 | +description: This article explains how to troubleshoot OpenSSH connection issues by using the `MaxStartups` and `MaxSessions` parameters to limit client connections to the OpenSSH Server service. |
| 4 | +ms.date: 10/13/2025 |
| 5 | +manager: dcscontentpm |
| 6 | +audience: itpro |
| 7 | +ms.topic: troubleshooting |
| 8 | +ms.reviewer: warrenw, kaushika, v-appelgatet |
| 9 | +ms.custom: |
| 10 | +- sap:system management components\openssh (including sftp) |
| 11 | +- pcy:WinComm User Experience |
| 12 | +appliesto: |
| 13 | +- ✅ <a href=https://learn.microsoft.com/windows/release-health/windows-server-release-info target=_blank>Supported versions of Windows Server</a> |
| 14 | +- ✅ <a href=https://learn.microsoft.com/windows/release-health/supported-versions-windows-client target=_blank>Supported versions of Windows Client</a> |
| 15 | +--- |
| 16 | + |
| 17 | +# How to use "MaxStartups" and "MaxSessions" to troubleshoot OpenSSH connection issues |
| 18 | + |
| 19 | +This guide explains how to use the `MaxStartups` and `MaxSessions` parameters to limit client connections to the OpenSSH Server service. |
| 20 | +These settings help you troubleshoot connection issues and manage unauthenticated and authenticated SSH sessions, especially in high-load environments. |
| 21 | + |
| 22 | +## Symptoms |
| 23 | + |
| 24 | +You can use `MaxStartups` and `MaxSessions` to address the following types of symptoms. |
| 25 | + |
| 26 | +- Symptom 1: Clients can't connect to the OpenSSH Server service and establish sessions. Additionally, you might receive the following error messages: |
| 27 | + |
| 28 | + - Connection reset by peer |
| 29 | + - Exceeded MaxStartups |
| 30 | + - Negotiation failed |
| 31 | + |
| 32 | +- Symptom 2: In an environment that supports session multiplexing (multiple sessions per connection), clients connect and authenticate. However, the server drops the connection. |
| 33 | + |
| 34 | +## Cause |
| 35 | + |
| 36 | +Symptom 1 indicates that too many client applications are connecting to the OpenSSH Server service at the same time. |
| 37 | + |
| 38 | +Symptom 2 is limited to multiplexing environments. It indicates that the OpenSSH Server service can't support the number of sessions per connection that the clients are using. This symptom can occur after you configure`MaxStartups`. |
| 39 | + |
| 40 | +## How to use the parameters |
| 41 | + |
| 42 | +`MaxStartups`and `MaxSessions` are parameters in the sshd_config file. The following sections explain how they function. |
| 43 | + |
| 44 | +### MaxStartups |
| 45 | + |
| 46 | +The `MaxStartups` parameter defines how many concurrent unauthenticated connections the OpenSSH Server service can manage. This setting is especially useful on servers that support multiple parallel SSH connections, including jump hosts and provisioning servers (such as servers that use Ansible). It's also useful in high-load environments or during brute-force attacks. |
| 47 | + |
| 48 | +The value is a set of three integers that are separated by colons, in the format `Start:Rate:Full`. The integers represent the following values: |
| 49 | + |
| 50 | +- **Start**: The number of unauthenticated connections that the OpenSSH Server service supports before it starts dropping connections. |
| 51 | +- **Rate**: Probability that the OpenSSH Server service drops a connection. As long as the number of concurrent sessions is below the `Start` value, the service ignores `Rate`. However, when the number of concurrent connections surpasses `Start`, each additional connection has a `Rate` percent probability of being dropped. |
| 52 | +- **Full**: When the number of concurrent connections surpasses `Full`, the service drops all additional connections. |
| 53 | + |
| 54 | +For example, consider a system that's using the configuration, `MaxStartups 20:40:60`. The OpenSSH Server service manages connections as follows: |
| 55 | + |
| 56 | +- The service maintains the first 20 concurrent unauthenticated connections. |
| 57 | +- Starting at the 21st connection attempt, there's a 40 percent probability that the server drops the new connection attempt. |
| 58 | +- After the service reaches 60 concurrent unauthenticated connections, the server rejects all further connection attempts. |
| 59 | + |
| 60 | +### MaxSessions |
| 61 | + |
| 62 | +The `MaxSessions` parameter defines how many open shell, login, or subsystem (for example, sftp) sessions that the OpenSSH Server service permits for each network connection. Setting `MaxSessions` to `1` effectively disables session multiplexing. Setting it to `0` prevents all shell, login, and subsystem sessions, but allows port forwarding. The default value is `10`. |
| 63 | + |
| 64 | +### How to set the connection parameters |
| 65 | + |
| 66 | +To modify the parameters for the Windows OpenSSH Server service, modify the sshd_config file, and then restart the OpenSSH Server service. To do this, follow these steps: |
| 67 | + |
| 68 | +1. Using an Administrator-level account, open a text editor, and then open **%ProgramData%\ssh\sshd_config**. The default text for these settings should resemble the following excerpt: |
| 69 | + |
| 70 | + ```output |
| 71 | + #MaxStartups 10 |
| 72 | + ``` |
| 73 | + |
| 74 | + ```output |
| 75 | + #MaxSessions 10 |
| 76 | + ``` |
| 77 | + |
| 78 | + > [!NOTE] |
| 79 | + > `MaxSessions` typically appears within the `# Authentication` section of the file. `MaxStartups` typically appears in a list of general options later in the file. |
| 80 | +
|
| 81 | +1. To enable `MaxStartup` or `MaxSessions` and to set values, edit the text to resemble the following excerpt: |
| 82 | + |
| 83 | + ```output |
| 84 | +
|
| 85 | + MaxStartups 20:40:60 |
| 86 | + ``` |
| 87 | + |
| 88 | + ```output |
| 89 | + MaxSessions 15 |
| 90 | + ``` |
| 91 | + |
| 92 | + > [!NOTE] |
| 93 | + > In this command, `20:40:60` and `15` are example values. Use values that are appropriate for your environment. |
| 94 | +
|
| 95 | +1. Save and close the sshd_config file. |
| 96 | + |
| 97 | +1. To verify the configuration, open a Windows PowerShell Command Prompt window, and then run the following command: |
| 98 | + |
| 99 | + ```powershell |
| 100 | + sshd -t |
| 101 | + ``` |
| 102 | +
|
| 103 | +1. To restart the OpenSSH Server service, open a Windows Command Prompt window, and then run the following command: |
| 104 | +
|
| 105 | + ```console |
| 106 | + NET STOP "OpenSSH SSH Server" && NET START "OpenSSH SSH Server" |
| 107 | + ``` |
| 108 | + |
| 109 | +After the service restarts, it uses the new parameter values. |
| 110 | + |
| 111 | +## More information |
| 112 | + |
| 113 | +- [Windows configurations in sshd_config](/windows-server/administration/OpenSSH/openssh-server-configuration#windows-configurations-in-sshd_config) in "OpenSSH Server configuration for Windows Server and Windows" |
| 114 | +- [sshd_config(5) - Linux manual page](https://man7.org/linux/man-pages/man5/sshd_config.5.html) |
| 115 | +- [sshd_config - OpenSSH daemon configuration file](https://man.openbsd.org/sshd_config) |
| 116 | + |
| 117 | +[!INCLUDE [Third-party disclaimer](../../includes/third-party-disclaimer.md)] |
0 commit comments