Skip to content

Instantly share code, notes, and snippets.

@talbergs
Created September 6, 2016 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talbergs/07208abcc9869e148d07db605f2acb14 to your computer and use it in GitHub Desktop.
Save talbergs/07208abcc9869e148d07db605f2acb14 to your computer and use it in GitHub Desktop.
php ssh example
$ip = '123.12.123.123';
$user = 'root';
$pass = 'pass';
$conn = ssh2_connect($ip);
ssh2_auth_password($conn, $user, $pass);
$stream = ssh2_exec($conn, 'whoami');
stream_set_blocking($stream, true);
echo stream_get_contents($stream); // root
// INSTALL EXTENSION -
// > sudo apt-get install libssh2-php
// > sudo /etc/init.d/apache2 restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment