Today in this tutorial i will go over the demonstration of how to Connect SSH using PHP. This article will goes to details on how to execute ssh command in php application. If you have any question about php execute ssh command on remote server . Then i will give you a very simple example with a good solution. Now I will help you to give you a good example of php execute remote ssh command. So Follow bellow tutorial steps for php run ssh command.
Now i will give you a very simple example to connect with ssh remove server and by run command using php.
So let’s see the example code:
<?php $host = '22.214.171.124'; $port = 22; $username = 'root'; $password = '00cd6bf584e....'; $connection = ssh2_connect($host, $port); ssh2_auth_password($connection, $username, $password); $stream = ssh2_exec($connection, 'df -h'); stream_set_blocking($stream, true); $output = stream_get_contents($stream); print_r($output); ?>
Hope it will help you… Also you can follow us on Facebook.