How to Connect SSH using PHP?
In this tutorial we will go over the demonstration of 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.
let's see example code:
$host = '220.127.116.11';
$port = 22;
$username = 'root';
$password = '00cd6bf584e....';
$connection = ssh2_connect($host, $port);
ssh2_auth_password($connection, $username, $password);
$stream = ssh2_exec($connection, 'df -h');
$output = stream_get_contents($stream);
i hope it can help you...
We are Recommending you
- PHP - How to replace image src in a dynamic HTML string
- Angular 10 Create New Component using Command
- How to Convert Array into Comma Separated String in Angular?
- How to Install Laravel in Ubuntu?
- How to Downgrade php 7.4 to 7.3 Ubuntu?
- How to install composer using command line in ubuntu ?
- How to Clear Log File using Command in Laravel?
- How to Uninstall a Package in Laravel Using Composer Command?
- How to Install Sublime Text Editor 3 in Ubuntu?
- How to Increase Upload File Size Limit PHP in Ubuntu?
- How to Find Day Name from Specific Date in PHP?