title: Read the Pre-login ssh banner from PHP
body: <p>I'm trying to use the libssh2-php library functions to connect to an ssh server from PHP. That's all great, but I can't figure out how to read the pre-login banner in PHP. The Pre-login banner is text displayed before SSH prompts for a login, and as far as I can tell I can't get a stream from the connection object.</p>
  
  <p>So given this code, is there any way to do a read prior to logging in?</p>
  
  <pre><code>&lt;?php
  if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist");
        // log in at server1.example.com on port 22 
  if(!($con = ssh2_connect("server1.example.com", 22))){
    echo "fail: unable to establish connection\n";
  } else {
  
   //####### Would really like to get a stream right here to read pre-login banner
  
  // try to authenticate with username root, password secretpassword
  if(!ssh2_auth_password($con, "root", "secretpassword")) {
      echo "fail: unable to authenticate\n";
  } else {
      // allright, we're in!
      echo "okay: logged in...\n";
  
      // execute a command
      if (!($stream = ssh2_exec($con, "ls -al" ))) {
          echo "fail: unable to execute command\n";
      } else {
          // collect returning data from command
          stream_set_blocking($stream, true);
          $data = "";
          while ($buf = fread($stream,4096)) {
              $data .= $buf;
          }
          fclose($stream);
      }
   }
  }
  ?&gt;
  </code></pre>