Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
php ssh example
$ip = '';
$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
// > 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
You can’t perform that action at this time.