Expect Issue Serial Forground Execution vs Concurrent Background Execution

I have an expect script that interrogates several hundred unix servers for both access and directories therein using "ssh user@host ls -l /path". The combination of host/path are unique but the host may be interrogated multiple times if there are multiple paths to test.

The expect script is run from a wrapper script that reads thru a file containing the host/path pairs. When I spawn off the expect script in the background without waiting for completion the result are, in some cases, quite different from when the expect script is run one at a time.

The error encountered when spawning off many expect scripts is "ssh_exchange_identification: Connection closed by remote host" which never happens when the expect script is run sequentially with implied wait.

Is the problem that a given server is being hit too fast with multiple ssh connection attempts or something else?

Any and all thoughts appreciated.

twk

You may well be right, but it's easy to test...try putting some sleeps in your script, and also use send_slow to send text at more like user typing speed.
Do you have a limit on the number of connections that you can connect to on any specific remote host, so it disconnected those it doesn't want?

Are there more than 10 directories on one host, or possibly other users using SSH, or sitting on an open connection? (I'm guilty of leaving ssh bash shells open for days; others probably are too.)

The config file has parameters MaxSessions and MaxStartups that could be affecting you. Especially if someone lowered their default values of 10 in /etc/ssh/sshd_config.

See man sshd_config.