title: phpseclib ssh2 enable tty
body: <p>my ssh script:</p>
  
  <pre><code>include('Net/SSH2.php');
  set_include_path(getcwd());
  
  
  
  $ssh_host = "myserver.com";
  if($ssh_host != null){
      $ssh_user = globals::$ssh_logins[$ssh_host];
      $ssh = new Net_SSH2($ssh_host);
      //$ssh-&gt;enablePTY();
      if (!$ssh-&gt;login($ssh_user['username'], $ssh_user['password'])) {
          echo $ssh-&gt;isConnected() ? 'bad username or password' : 'unable to establish connection';
      }
      echo $ssh-&gt;exec('sudo bash /myscript.sh');
  }else{
      echo "no host: " . $ssh_host;
  }
  </code></pre>
  
  <p>when calling:</p>
  
  <pre><code>echo $ssh-&gt;exec('sudo bash /myscript.sh');
  </code></pre>
  
  <p>i get the output:</p>
  
  <pre><code>stdin: is not a tty
  sudo: sorry, you must have a tty to run sudo
  </code></pre>
  
  <p><strong>how do i enable tty on phpseclib?</strong>
  Sudo is necessary also it is important to retrieve the output. my script returns multiple lines.</p>
  
  <ul>
  <li>Centos 7</li>
  <li>PHP 7</li>
  </ul>
  
  <p>interesting link: <a href="https://unix.stackexchange.com/questions/136676/sudo-sorry-you-must-have-a-tty-to-run-sudo-when-using-sudo-in-a-remote-scrip?newreg=f31852b195804fd1b988aeb0a9ce59d9">https://unix.stackexchange.com/questions/136676/sudo-sorry-you-must-have-a-tty-to-run-sudo-when-using-sudo-in-a-remote-scrip?newreg=f31852b195804fd1b988aeb0a9ce59d9</a></p>