Created
September 6, 2016 20:48
-
-
Save talbergs/07208abcc9869e148d07db605f2acb14 to your computer and use it in GitHub Desktop.
php ssh example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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