PHP function ssh2_connect is not working
I have installed the SSH2 PECL extension and its working fine thanks all for you help...
SSH2 Connect Issues
Because you are in the namespace of the Controllers
you might need to use:
$connection = \ssh2_connect($request->sever_ip, 2222);
if (!$connection) die('Connection failed');
Having trouble with PHP-SSH2 connecting to remote server
Try these changes:
function execute($address,$user, $password, $command){
$connection = ssh2_connect($address, 22);
if(ssh2_auth_password($connection, $user, $password)){
echo ssh2_exec($connection, $command);
}else {
die("Could not connect to server...");
}
}
execute($address,$user, $password, $command);
The variables that you were referencing inside the function weren't actually available, they need to either be passed in as parameters when calling the function as I've done in the snippet above or by declaring them globally inside the function.
Related Topics
Leverage Browser Caching for 3Rd Party Js
New Limit Within PHP: 1000 Fields Per Post. Does Someone Know, If the Number Can Be Influenced
PHP Messing with HTML Charset Encoding
PHP Link to Image File Outside Default Web Directory
How to Get MAC Address of Client Using PHP
How to Connect to Mssql Using Pdo Through PHP and Linux
Jquery Ajax Form Using Mail() PHP Script Sends Email, But Post Data from HTML Form Is Undefined
PHP Function to Get Mp3 Duration
Php: Convert Milliseconds to Date
Find Out Which Class Called a Method in Another Class
Laravel 5.3 Auth Check in Constructor Returning False
Unique and Temporary File Names in PHP