我有一个脚本,它 rsync 是大约 10 个远程服务器的本地目录。它基本上有一个服务器列表,并通过它们中的每一个进行 rsync 循环。为了加快这个过程,我为每个 rsync 分叉,以便所有 10 个并行发生。问题是最后几台服务器返回“ssh_exchange_identification:连接被远程主机关闭”。单独或串行执行 rsync 时不会发生这种情况,并且在每个 rsync 之间放置半秒延迟可以解决问题(通常,有时列表中的最后一个服务器仍会返回错误)。
有谁知道为什么会发生这种情况?我认为这是 rysnc 的问题,而不是我的脚本,因为无论如何脚本只是对 rysnc 进行系统调用。
我以前见过这个问题。您需要MaxStartups
在要连接的 SSH 服务器上提高值。请注意,默认值为 10。您可以通过编辑/etc/ssh/sshd_config
和重新加载 SSH 守护程序(希望您控制远程服务器)来完成此操作。
来自man sshd_config
:
MaxStartups
Specifies the maximum number of concurrent unauthenticated connections to the SSH daemon. Additional connections will be dropped until authentication succeeds or the
LoginGraceTime expires for a connection. The default is 10.
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) unauthenticated connections. The probability increases linearly and all connection attempts are
refused if the number of unauthenticated connections reaches “full” (60).
Run Code Online (Sandbox Code Playgroud)