MultiSsh
in package
A wrapper around Spatie\Ssh to connect sequentially to an array of ssh servers
Tags
Table of Contents
Methods
- __construct() : mixed
- Establishes a connection to all hosts passed in $cfg
- execute() : MultiSsh
- Executes a command on all hosts
- getOutput() : array<string|int, mixed>
- Returns the out put
- removeHost() : mixed
- Removes a host from the ssh connections
- upload() : MultiSsh
- Uploads a file to every host
Methods
__construct()
Establishes a connection to all hosts passed in $cfg
public
__construct(Settings|array<string|int, mixed> $cfg) : mixed
Parameters
- $cfg : Settings|array<string|int, mixed>
-
of the form
[ 'key' => [ 'host' => '', 'user' => '', ('port' => '') ], (...) ]
Tags
execute()
Executes a command on all hosts
public
execute(string $cmd[, Closure $onOutput = null ]) : MultiSsh
Parameters
- $cmd : string
-
The shell command to execute
- $onOutput : Closure = null
-
Closure to render rhe output, if not set, output is omitted
Tags
Return values
MultiSsh —Returns itself
getOutput()
Returns the out put
public
getOutput() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —the output of the ssh command as array of every process
removeHost()
Removes a host from the ssh connections
public
removeHost(string $id) : mixed
Parameters
- $id : string
-
The key of the host, as passed in the constructor, to remove
Tags
upload()
Uploads a file to every host
public
upload(string $src, string $dest[, Closure $onOutput = null ]) : MultiSsh
Parameters
- $src : string
-
The path of the file to upload
- $dest : string
-
The patn on the server to upload the file to
- $onOutput : Closure = null
-
Closure to render rhe output, if not set, output is omitted
Tags
Return values
MultiSsh —Returns itself