это моя функция контроллера < /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
Почему Spatie SSH не работает, и не показывает мне ошибку? ⇐ Php
Кемеровские программисты php общаются здесь
-
Anonymous
1739965772
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?
Подробнее здесь: [url]https://stackoverflow.com/questions/79451213/why-spatie-ssh-not-working-and-not-any-type-of-error-is-showing-to-me[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия