slava-vishnyakov / ssh-connection
PHP SSH Connection
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/slava-vishnyakov/ssh-connection
Requires
- php: ^7.1
- ext-mbstring: *
- phpseclib/phpseclib: ^2.0
Requires (Dev)
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2020-01-21 11:35:20 UTC
README
composer require slava-vishnyakov/ssh-connection
Use
use SlavaVishnyakov\SshConnection\SshConnection; $ssh = new SshConnection($username, '127.0.0.1:2222'); $ssh->privateKeyPath = 'my_private_key'; // $ssh->privateKeyPassword = ''; // $ssh->useAgent = true; $ssh->connectAndReadMotd(); $result = $ssh->run('echo Hello'); print($result->stdout); // "Hello" print($result->stderr); // "" print($result->exitCode); // 0 $ssh->sudoPassword = 'vagrant'; $result = $ssh->sudoRun('whoami');
Testing
vagrant up phpunit
TODO
- Test escaping in run / sudoRun