Closed qannoufoualid closed 6 years ago
Are you still experiencing this issue?
After reading and debugging the code of the API (Yeah I know I suffered a lot). This API unfortunately requires FTP server to be running in the target server :\ which make no sens. So i got rid of that API and used the Pure-PHP implementation of SSHv2. This is a the class I created :
<?php namespace App\Services;
use SSH;
class SSHService {
public function execute(array $serverData, array $commands){
$host = $serverData['host'];
$port = $serverData['port'];
$userName = $serverData['userName'];
$password = $serverData['password'];
$ssh = new \Net_SSH2($host);
if (!$ssh->login($userName, $password)) {
throw new \Exception('Unable to connect to server');
}
$output = '';
foreach ($commands as $command){
$output.= $ssh->exec($command);
}
return trim($output);
}
}
Yeah I'm not sure why a new SFTP instance is always created. Maybe we should implement some sort of driver configuration where a user is able to set driver to 'sftp' or 'ssh' and separate the two gateways
Yes, that's gonna be better. because there is no need to use FTP in case you want to use only SSH requests.
I want to execute some commands in a remote server using SSH. This is my configuration :
I tried this :
SSH::into('production')->run(['ls']);
but i get the following error:Unable to connect to remote server
with no additional informations explaining why it doesn't work. Note:The RSA key is correct and i can use it to login to the server using cygwin.
Even with a correct password it doesn't work.
I have all the permissions on the folder C:\cygwin64\home\oqannouf.ssh\