linux + ssh ограничение + ssh одновременно с нескольких машин на одну машину - PullRequest
1 голос
/ 13 февраля 2012

следующий скрипт "testssh.ksh" доказывает, что у ssh есть некоторые проблемы, когда мы пытаемся выполнить ssh с нескольких машин одновременно

на самом деле цель этого скрипта - проверить файл test_file в/ var / tmp на сервере Solaris (10.10.18.6), как все видят в некоторых шагах ssh, мы не можем проверить наличие файла test_file, потому что ssh застрял или не активирован из ожидаемого

фона - этот скриптвыполнить 15 раз ssh на сервер Solaris с IP - 10.10.18.6 в одно и то же время, чтобы проверить file_test в / var / tmp на сервере

мой вопрос - как улучшить процесс ssh, чтобы избежатьследующие проблемы

Замечание - сон может помочь нам в этой ситуации - но я не хочу добавлять сон перед процессом ssh

  [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

пример - когда мы запускаем скрипт 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

1 Ответ

5 голосов
/ 15 февраля 2012

Вы установили MaxSession и MaxStartups в sshd.conf (или эквивалентном)? Я полагаю, что одновременных 40 соединений SSH не должно быть слишком много для вашего сервера.

С man sshd_config страница:

 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).

Если вы не изменили их, ваш сервер не будет обрабатывать более 10 одновременных подключений.

Аналогичный вопрос (serverfault.com).

...