Hello everyone
I'm going to try to explain my problem as clear as possible, feel free to ask me more precision if you didn't understand what I meant and forgive my English this is not my mother tongue.
My goal
What I want to do looks simple. Let's say I have 2 servers: S1 and S2.
S1 is the server on which one I have my Laravel 5.5 installed and running.
S2 is a server where I have multiples PHP scripts.
I want to run a PHP script (which is on S2) from a simple click on a button in my Laravel App.
The command I want to run is php theNameOfMyFiles
The things you have to know
- In command line, I can connect in SSH to S2 via S1:
ssh -tt -p 2222 myRemoteUser@myRemoteIp
. This is working properly. - Most of my test will show some tries of folder creation because it is easier to see if a folder has been created instead of checking if a script is running.
My different tries
To reach that goal, I tried a bunch of things. First of all, I am using Laravelcollective SSH 5.2 to be able to use SSH from my Laravel app.
My configuration file config/remote.php
, this is where I specify my remote server connections :
return [
default' => 'S1',
'connections' => [
'S1' => [
'host' => '127.0.0.1',
'username' => 'myUsername',
'password' => 'myPassword',
'key' => '',
'keytext' => '',
'keyphrase' => '',
'agent' => '',
'timeout' => 10,
],
'S2' => [
'host' => 'myRemoteIP',
'username' => 'myRemoteUser',
'port' => '2222',
'password' => '',
'key' => '',
'keytext' => '',
'keyphrase' => '',
'agent' => '',
'timeout' => 30,
'directory' => '/home/myRemoteUser/'
]
Try 1
SSH::into('S2')->run(['mkdir imAtestDirectory']);
Each time I tried to use SSH::into('S2')
I'm getting an Unable to connect to remote server
RuntimeException.
I tried without any SSH key, with my private/public SSH key in the keytext field but I'm still getting the same error.
I tried to put the path to my keys in the key field, but it says the file ~/.ssh/mykey
doesn't exist.
Moving my keys to another place isn't working either, I'm getting the Unable to connect to remote server
again.
Try 2
SSH::into('S1')->run(['ssh -tt -p 2222 myRemoteUser@myRemoteIp', 'mkdir testDir'])
I tried to reproduce exactly what I was doing in command line because I know that can work. I feel like I'm connecting to S2, when I'm looking at what the SSH command is returning I'm getting [...] The programs included with the Debian GNU/Linux system are free software [...]
which is the same message I'm getting when I'm doing the command in command line , but it's not creating the folder.
Help me, please
I'm running out of ideas, I've been googling for hours but I can't find how to resolve my problem or any other way of doing what I want to do what I want.
If you need any more precision, feel free to ask.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2NvDzAk
via IFTTT
Aucun commentaire:
Enregistrer un commentaire