Advertisement
Guest User

Untitled

a guest
May 30th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.99 KB | None | 0 0
  1. <?php
  2.  
  3. require_once ('ssh_in_php.php');
  4.  
  5. $host = "127.0.0.1";
  6. $port = 22;
  7. $user = "user";
  8. $password = "pass";
  9.  
  10. try {
  11.     $ssh = new SSH_in_PHP($host,$port);
  12.     $ssh->connect($user,$password);
  13.  
  14.     $cycle = true;
  15.     while ($cycle) {
  16.         $data = $ssh->read();
  17.         echo $data;
  18.         if (ereg('\$',$data)) {
  19.             $cycle = false;
  20.         }
  21.     }
  22.     $ssh->write("uname -a\n");
  23.     $cycle = true;
  24.     while ($cycle) {
  25.         $data = $ssh->read();
  26.         echo $data;
  27.         if (ereg('\$',$data)) {
  28.             $cycle = false;
  29.         }
  30.     }
  31.    
  32.     $ssh->write("ls -al\n");
  33.     $cycle = true;
  34.     while ($cycle) {
  35.         $data = $ssh->read();
  36.         echo $data;
  37.         if (ereg('\$',$data)) {
  38.             $cycle = false;
  39.         }
  40.     }
  41.  
  42.     $ssh->disconnect();
  43.  
  44. } catch (SSHException $e) {
  45.     echo "An Exception Occured: {$e->getMessage()} ({$e->getCode()})\n";
  46.     echo "Trace: \n";
  47.     echo print_r($e->getTrace());
  48.     echo "\n";
  49. }
  50.  
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement