Advertisement
Guest User

Untitled

a guest
Mar 11th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. <?php
  2. $server = "host";
  3. $username = "login";
  4. $password = "haslo";
  5.  
  6. $methods = array('kex' => 'diffie-hellman-group1-sha1');
  7.  
  8. $connection = ssh2_connect($server, 22, $methods);
  9. ssh2_auth_password($connection, $username, $password);
  10. $shell = ssh2_shell($connection);
  11. $cmd = "df -h";
  12. $output = user_exec($shell,$cmd);
  13.  
  14. function user_exec($shell,$cmd)
  15. {
  16. fwrite($shell, $cmd . "\r");
  17. sleep(1);
  18. while($line = fgets($output)){
  19. flush();
  20. $tab[]= $line;
  21. }
  22. fclose($shell);
  23. }
  24.  
  25.  
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement