MaxStartups and MaxSessions configurations parameter for ssh connections?

Posted by Webby on Server Fault See other posts from Server Fault or by Webby
Published on 2014-06-11T07:31:18Z Indexed on 2014/06/11 9:27 UTC
Read the original article Hit count: 608

Filed under:
|
|
|
|

I am copying the files from machineB and machineC into machineA as I am running my below shell script on machineA.

If the files is not there in machineB then it should be there in machineC for sure so I will try copying the files from machineB first, if it is not there in machineB then I will try copying the same files from machineC.

I am copying the files in parallel using GNU Parallel library and it is working fine. Currently I am copying 10 files in parallel.

Below is my shell script which I have -

#!/bin/bash

export PRIMARY=/test01/primary
export SECONDARY=/test02/secondary
readonly FILERS_LOCATION=(machineB machineC)
export FILERS_LOCATION_1=${FILERS_LOCATION[0]}
export FILERS_LOCATION_2=${FILERS_LOCATION[1]}
PRIMARY_PARTITION=(550 274 2 546 278) # this will have more file numbers
SECONDARY_PARTITION=(1643 1103 1372 1096 1369 1568) # this will have more file numbers

export dir3=/testing/snapshot/20140103

find "$PRIMARY" -mindepth 1 -delete
find "$SECONDARY" -mindepth 1 -delete

do_Copy() {
  el=$1
  PRIMSEC=$2
  scp david@$FILERS_LOCATION_1:$dir3/new_weekly_2014_"$el"_200003_5.data $PRIMSEC/. || scp david@$FILERS_LOCATION_2:$dir3/new_weekly_2014_"$el"_200003_5.data $PRIMSEC/.
}
export -f do_Copy

parallel --retries 10 -j 10 do_Copy {} $PRIMARY ::: "${PRIMARY_PARTITION[@]}" &
parallel --retries 10 -j 10 do_Copy {} $SECONDARY ::: "${SECONDARY_PARTITION[@]}" &
wait    

echo "All files copied."

Problem Statement:-

With the above script at some point I am getting this exception -

ssh_exchange_identification: Connection closed by remote host
ssh_exchange_identification: Connection closed by remote host
ssh_exchange_identification: Connection closed by remote host

And I guess the error is typically caused by too many ssh/scp starting at the same time. That leads me to believe /etc/ssh/sshd_config:MaxStartups and MaxSessions is set too low.

But my question is on which server it is pretty low? machineB and machineC or machineA? And on what machines I need to increase the number?

On machineA this is what I can find -

root@machineA:/home/david# grep MaxStartups /etc/ssh/sshd_config
#MaxStartups 10:30:60

root@machineA:/home/david# grep MaxSessions /etc/ssh/sshd_config

And on machineB and machineC this is what I can find -

[root@machineB ~]$ grep MaxStartups /etc/ssh/sshd_config
#MaxStartups 10

[root@machineB ~]$ grep MaxSessions /etc/ssh/sshd_config
#MaxSessions 10

© Server Fault or respective owner

Related posts about linux

Related posts about ssh