默认的登录尝试率限制是多少?

默认的登录尝试率限制是多少?

在使用 OpenSSH 的标准 Linux 安装中,使用密码验证的 SSH 登录尝试的默认速率限制是多少?

攻击者每小时可以猜出多少个密码?

答案1

在每个连接上,密码提示都有特定的限制。它由选项定义MaxAuthTries(默认为 6)。但您不能一次尝试所有密码。每次失败后,您都会受到一些时间惩罚(大约 3 秒钟的延迟来运行 PAM 堆栈)。

攻击者可以按照受限制的速率发出连接MaxStartups(默认为 10:30:100,如果有 10 个未经身份验证的连接打开,将开始拒绝连接)。

LoginGraceTime选项与攻击者无关,因为它仅定义了如果攻击者未能成功验证,服务器关闭连接之前的最长时间。

这里的限制因素主要是密钥交换,这需要时间,因为:

  • 加密需要 CPU 时间——取决于服务器和客户端处理器或加速器
  • 往返时间——取决于地理距离

我的快速测试表明,与另一个房间的 Raspberry Pi 建立连接大约需要 1 秒。但它可以更快,SSHD 可以处理更多并行请求。来自本地主机的密码提示几乎是即时的。

假设攻击者可以简单地并行发出 10 个连接,等待 1 秒提示,输入一个密码,等待 3 秒提示第二次提示(或确认密码确实正确)(...重复 6 次直到它退出)。这需要 1 + 3 * 6 秒(19 秒)在单个线程中尝试 6 次密码,在 10 个线程中尝试 60 次密码。在这个乐观的情况下,一分钟四舍五入为 180 次,一小时四舍五入为 10k 次。

请注意,攻击者可以将线程数量增加到 20 个或更多,而拒绝的概率相当低,但尝试次数可以增加两倍(甚至更多,但不能超过 100 次)。这就是存在的原因fail2ban

答案2

人sshd_config:

 MaxStartups
         Specifies the maximum number of concurrent unauthenticated con‐
         nections to the SSH daemon.  Additional connections will be
         dropped until authentication succeeds or the LoginGraceTime
         expires for a connection.  The default is 10:30:100.

         Alternatively, random early drop can be enabled by specifying the
         three colon separated values “start:rate:full” (e.g. "10:30:60").
         sshd(8) will refuse connection attempts with a probability of
         “rate/100” (30%) if there are currently “start” (10) unauthenti‐
         cated connections.  The probability increases linearly and all
         connection attempts are refused if the number of unauthenticated
         connections reaches “full” (60).

相关内容