Php Secure Shell2 (ssh2) Unable to request command execution onremote host

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Varlamov Konstantyn

    #1

    Php Secure Shell2 (ssh2) Unable to request command execution onremote host

    I have simple script:
    <?php


    $connection = ssh2_connect("i p", 22);
    ssh2_auth_passw ord($connection ,"login","test" );




    sleep(10);


    ssh2_exec($conn ection,"show log\n");




    ?>
    Error message:
    Unable to request command execution on remote host in
    /home/konstantyn/www/php/test/11.php5 on line 13

    Help me please....
    Greetings,
    Konstantyn Varlamov
  • Rami Elomaa

    #2
    Re: Php Secure Shell2 (ssh2) Unable to request command executionon remote host

    Varlamov Konstantyn kirjoitti:
    Help me please....
    Greetings,
    Konstantyn Varlamov
    You've asked now repeatedly several times the same thing. I'm sure that
    if someone knows the answer, he or she will answer you, but for now
    you'll just need to cool down and wait for a while. It doesn't help at
    all that you keep asking the same thing over and over. The question is
    here now and the people will try to help you with your trouble. Just
    wait. If you feel you need to add something to the original question,
    reply in one of the threads you've started, but please don't start any
    new threads anymore. Patience is a virtue.

    --
    Rami.Elomaa@gma il.com

    "Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
    usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze

    Comment

    • Charles Polisher

      #3
      Re: Php Secure Shell2 (ssh2) Unable to request command execution on remote host

      On 2007-07-05, Varlamov Konstantyn <konstantyn17@g mail.comwrote:
      I have simple script:
      ><?php
      >
      >
      $connection = ssh2_connect("i p", 22);
      Here, you can check $connection, as in:
      if (! $connection) {
      die("Connection failed.");
      }
      ssh2_auth_passw ord($connection ,"login","test" );
      Here, you can check if the auth succeeded, as in:
      if (! ssh2_auth_passw ord($connection ,"login","test" )) {
      die("Auth failed.");
      }
      sleep(10);
      >
      >
      ssh2_exec($conn ection,"show log\n");
      Is "show log" a valid command? I think this
      is what may be messing you up. Try something simple
      like "/bin/ls", also you want to set a variable
      as in:
      $stream = ssh_2exec($conn ection, ...);
      and then I think you might trying examining $stream:
      stream_set_bloc king($stream, true);
      $output = stream_get_cont ents($stream);
      ?>
      Error message:
      Unable to request command execution on remote host in
      /home/konstantyn/www/php/test/11.php5 on line 13
      >
      Help me please....
      Greetings,
      Konstantyn Varlamov
      Hope this helps a little,

      Charles

      Comment

      • Varlamov Konstantyn

        #4
        Re: Php Secure Shell2 (ssh2) Unable to request command executionon remote host

        Rami Elomaa пишет:
        Varlamov Konstantyn kirjoitti:
        >
        >Help me please....
        >Greetings,
        >Konstantyn Varlamov
        >
        You've asked now repeatedly several times the same thing. I'm sure that
        if someone knows the answer, he or she will answer you, but for now
        you'll just need to cool down and wait for a while. It doesn't help at
        all that you keep asking the same thing over and over. The question is
        here now and the people will try to help you with your trouble. Just
        wait. If you feel you need to add something to the original question,
        reply in one of the threads you've started, but please don't start any
        new threads anymore. Patience is a virtue.
        >
        I am undrestend)I am waiting)

        Comment

        • Varlamov Konstantyn

          #5
          Re: Php Secure Shell2 (ssh2) Unable to request command executionon remote host

          <?php


          $connection = ssh2_connect("l ogin", 22);

          if (! $connection) {
          die("Connection failed.");
          }
          else echo "connect OK";



          if (! ssh2_auth_passw ord($connection ,"user","test") ) {
          die("Auth failed.");
          }
          else echo "login OK";
          sleep(10);


          $stream=ssh2_ex ec($connection, "show log\n");
          stream_set_bloc king($stream, true);
          $output = stream_get_cont ents($stream);

          ?>

          connect OKlogin OK
          Warning: ssh2_exec(): Unable to request command execution on remote host
          in /home/konstantyn/www/php/test.php5 on line 22

          Warning: stream_set_bloc king(): supplied argument is not a valid stream
          resource in /home/konstantyn/www/php/test.php5 on line 25

          Warning: stream_get_cont ents() expects parameter 1 to be resource,
          boolean given in /home/konstantyn/www/php/test.php5 on line 26

          Re:

          The remote server is not a computer, it`s Dlink DES-3526 Ethernet Switch.
          Command "show log" is valid comand for him.
          Connection and login works but command executing triggers error.


          Comment

          • Charles Polisher

            #6
            Re: Php Secure Shell2 (ssh2) Unable to request command execution on remote host

            Varlamov wrote:
            $stream=ssh2_ex ec($connection, "show log\n");
            Maybe newline is not wanted?

            Comment

            • Varlamov Konstantyn

              #7
              Re: Php Secure Shell2 (ssh2) Unable to request command executionon remote host

              Tis is not work to
              <?php


              $connection = ssh2_connect("l ogin", 22);

              if (! $connection) {
              die("Connection failed.");
              }
              else echo "connect OK";



              if (! ssh2_auth_passw ord($connection ,"user","test") ) {
              die("Auth failed.");
              }
              else echo "login OK";
              sleep(10);


              $stream=ssh2_ex ec($connection, "show log");
              stream_set_bloc king($stream, true);
              $output = stream_get_cont ents($stream);

              ?>

              connect OKlogin OK
              Warning: ssh2_exec(): Unable to request command execution on remote host
              in /home/konstantyn/www/php/test.php5 on line 22

              Warning: stream_set_bloc king(): supplied argument is not a valid stream
              resource in /home/konstantyn/www/php/test.php5 on line 25

              Warning: stream_get_cont ents() expects parameter 1 to be resource,
              boolean given in /home/konstantyn/www/php/test.php5 on line 26

              Comment

              Working...