Closed OleVik closed 7 years ago
I found a solution. In the controller method, set the configuration values on runtime:
public function tryRemote()
{
$target = [
'host' => '127.0.0.1',
'username' => 'User',
'password' => '',
'key' => 'keyfile-absolute-path',
'keytext' => '',
'keyphrase' => 'phrase',
'agent' => '',
'timeout' => 10,
];
config([
'remote.connections.runtime.host' => $target['host'],
'remote.connections.runtime.username' => $target['username'],
'remote.connections.runtime.keyhost' => $target['key'],
'remote.connections.runtime.keyphrase' => $target['keyphrase']
]);
$commands = [
'cd'
];
\SSH::run($commands, function($line)
{
echo $line.PHP_EOL;
});
}
Running with Laravel 5.4, I set up a table to add connections for use with SSH.
$server = \App\Server::find(1)->first()->toArray()
returns a full configuration, and I tried to apply it like this (inremote.php
):But this returns:
Is there a way to call dynamic data in
remote.php
, or pass it when constructing SSH? For example, in a controller I run:Could I pass the connection-details into SSH before executing
run()
?