Reputation:
the following script "testssh.ksh" proves that ssh have some problems when we try to perform ssh from multiple machines on the same time
in fact the target of this script is to verify the file test_file under /var/tmp in the Solaris server (10.10.18.6) , as all see in some ssh steps we can’t verify the existing of the test_file because ssh stuck or not activate from the expect
background - this script perform 15 times ssh to Solaris server with IP - 10.10.18.6 on the same time in order to verify the file_test under /var/tmp in the server
my question - how to improve the ssh process in order to avoid the following problems
Remark - sleep can help us in this situation - but I not want to add sleep before ssh process
[root@linux /var/tmp]# more testssh.ksh
#!/bin/ksh
expect=`cat << EOF
set timeout -1
spawn ssh 10.10.18.6
expect {
")?" { send "yes\r" ; exp_continue }
word: {send pass123\r}
}
expect > {send "ls /var/tmp/test_file\r"}
expect > {send exit\r}
expect eof
EOF`
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
do
( expect -c "$expect" | grep "test_file" | grep -v ls ) &
done
example - when we run the script testssh.ksh
[root@linux /var/tmp]# /var/tmp/testssh.ksh
/var/tmp/test_file
/var/tmp/test_file
/var/tmp/test_file
/var/tmp/test_file
/var/tmp/test_file
expect: spawn id exp6 not open
while executing
"expect > {send "ls /var/tmp/test_file\r"}"
expect: spawn id exp6 not open
while executing
"expect > {send "ls /var/tmp/test_file\r"}"
expect: spawn id exp6 not open
while executing
"expect > {send "ls /var/tmp/test_file\r"}"
expect: spawn id exp6 not open
while executing
"expect > {send "ls /var/tmp/test_file\r"}"
/var/tmp/test_file
/var/tmp/test_file
/var/tmp/test_file
/var/tmp/test_file
/var/tmp/test_file
/var/tmp/test_file
Upvotes: 1
Views: 8680
Reputation: 72657
Have you set the MaxSession
and MaxStartups
in your sshd.conf
(or equivalent)? 40 simultaneous SSH connections should not, I believe, be too many for your server to handle.
From man sshd_config
page:
MaxSessions
Specifies the maximum number of open sessions permitted per net‐
work connection. The default is 10.
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.
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).
If you haven't changed these, your server won't handle more than 10 simultaneous connections.
Similar question (serverfault.com).
Upvotes: 5