LaravelCollective remote is not anymore manteined and I had to upgrade my applications to Laravel 10.
The latest version support is blocked to Laravel 8 and there is no way to install it using composer.
So I decided to write a small Service using the same basic interfaces for the LaravelCollective/remote package using the phpseclib version 3.
Usage
use App\Services\SshService as SSH;
$username = 'root';
$password = 'password';
$id = 'my-host';
config(['remote.connections.' . $id => [
'host' => '127.0.0.1:22',
'username' => $username,
'password' => $password,
'key' => '',
'keytext' => '',
'keyphrase' => '',
'agent' => '',
'timeout' => 0,
]]);
$connection = SSH::into($id);
// run a command
$output = $connection->run('ls -la');
// run multiple commands
$output = $connection->run(['ls -la', 'pwd']);
// upload a file
$connection->putFile('test.txt');
// create a file remotely
$connection->putString('test.txt', 'content of the file');