大网数据广告活动
Windows Server 管理

Use "MaxStartups" and "MaxSessions" to Troubleshoot OpenSSH Connection Issues

· 52CE 我爱测

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.

This guide explains how to use the MaxStartups and MaxSessions parameters to limit client connections to the OpenSSH Server service. These settings help you troubleshoot connection issues and manage unauthenticated and authenticated SSH sessions, especially in high-load environments.

Symptoms

You can use MaxStartups and MaxSessions to address the following types of symptoms.

  • Symptom 1: Clients can't connect to the OpenSSH Server service and establish sessions. Additionally, you might receive the following error messages:

    • Connection reset by peer
    • Exceeded MaxStartups
    • Negotiation failed
  • Symptom 2: In an environment that supports session multiplexing (multiple sessions per connection), clients connect and authenticate. However, the server drops the connection.

Cause

Symptom 1 indicates that too many client applications are connecting to the OpenSSH Server service at the same time.

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 configureMaxStartups.

How to use the parameters

MaxStartupsand MaxSessions are parameters in the sshd_config file. The following sections explain how they function.

MaxStartups

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.

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:

  • Start: The number of unauthenticated connections that the OpenSSH Server service supports before it starts dropping connections.
  • 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.
  • Full: When the number of concurrent connections surpasses Full, the service drops all additional connections.

For example, consider a system that's using the configuration, MaxStartups 20:40:60. The OpenSSH Server service manages connections as follows:

  • The service maintains the first 20 concurrent unauthenticated connections.
  • Starting at the 21st connection attempt, there's a 40 percent probability that the server drops the new connection attempt.
  • After the service reaches 60 concurrent unauthenticated connections, the server rejects all further connection attempts.

MaxSessions

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.

How to set the connection parameters

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:

  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:

    #MaxStartups 10
    
    #MaxSessions 10
    

    [!NOTE]
    MaxSessions typically appears within the # Authentication section of the file. MaxStartups typically appears in a list of general options later in the file.

  2. To enable MaxStartup or MaxSessions and to set values, edit the text to resemble the following excerpt:

    
    MaxStartups 20:40:60
    
    MaxSessions 15
    

    [!NOTE]
    In this command, 20:40:60 and 15 are example values. Use values that are appropriate for your environment.

  3. Save and close the sshd_config file.

  4. To verify the configuration, open a Windows PowerShell Command Prompt window, and then run the following command:

    sshd -t
    
  5. To restart the OpenSSH Server service, open a Windows Command Prompt window, and then run the following command:

    NET STOP "OpenSSH SSH Server" && NET START "OpenSSH SSH Server"
    

After the service restarts, it uses the new parameter values.

More information

Third-party information disclaimer

The third-party products that this article discusses are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, about the performance or reliability of these products.

Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / IT Pro troubleshooting
适用范围
See source applicability · Source date 02/12/2026
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。