How To Execute ssh Command In PHP?
Hi Guys,
Today,I will learn you how to connect ssh using php?. This article goes in detailed on how to execute ssh command in php. if you have question about php execute ssh command on remote server then i will give simple example with solution. we will help you to give example of php execute remote ssh command. Follow bellow tutorial step of php run ssh command.
I will give you very simple example to connect with ssh remove server and run command using php.
index.php
$host = '222.222.222.222';
$port = 22;
$username = 'root';
$password = '00fd7bf584e....';
$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);
?>
Output
It will help you...
- How To Use Php Conditional Statement Example
- How to Check if String Contains Regex in PHP?
- PHP Array_column() Function Example
- PHP Generate List of Random Numbers Between 0 and 100 Example
- How to User Login with Facebook in PHP?
- How to Explode Every Character into Array Using PHP Example?
- PHP Form Validation Tutorial
- PHP Convert XML to JSON Example