A new PHP package released by the fine folks at Spatie is
Symfony\Component\Process\Process it allows you to execute commands over SSH from within your PHP code.
spatie/sshis probably the easiest way to perform a quick SSH command. It doesn’t have a lot of features, but that’s ok. It’s intended as something very lightweight.
$process = Ssh::create('user', 'example.com') ->usePort(2222) ->usePrivateKey('/home/user/.ssh/id_rsa') ->execute('your favorite command');
Also comes with
upload functions, using
scp under the hood.
Installation per composer:
composer require spatie/ssh
how to pass password
Leave a comment