Почему Spatie SSH не работает, и не показывает мне ошибку?Php

Кемеровские программисты php общаются здесь
Ответить
Anonymous
 Почему Spatie SSH не работает, и не показывает мне ошибку?

Сообщение Anonymous »

это моя функция контроллера < /p>
public function ssh()
{
$privateKey = file_get_contents(storage_path('app/key/id_rsa'));
try {
$output = Ssh::create('root', 'c***.com')
->usePrivateKey($privateKey)
->disableStrictHostKeyChecking()
->execute('ls -la');

if ($output->isSuccessful()) {
dd($output->getOutput()); // Shows output if command runs successfully
} else {
dd('Command failed: ' . $output->getErrorOutput()); // Shows errors if command fails
}
} catch (\Exception $e) {
dd($e->getMessage());
}
}
< /code>
Route::get('/ssh', [SshController::class, 'ssh']);
< /code>
and if i try to run using terminal
ssh -i storage/app/key/id_rsa root@c**t.com
< /code>
it works without requiring password but not in laravel
and then i tried Running SSH Manually in PHP
public function ssh()
{
$cmd = 'ssh -i ' . escapeshellarg(storage_path('app/key/id_rsa')) . ' root@c***t.com "ls -la" 2>&1';
exec($cmd, $output, $status);

if ($status === 0) {
dd($output);
} else {
dd('Command failed: ' . implode("\n", $output));
}
}
< /code>
and suprisingly worked? can anyone help me whats the issue here?

Подробнее здесь: https://stackoverflow.com/questions/794 ... wing-to-me
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Php»