PHP Function Ssh2_Connect Is Not Working

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



Leave a reply



Submit