herzult/php-ssh
A lightweight PHP library for running SSH commands locally or remotely with a fluent API. Execute commands, capture stdout/stderr and exit codes, handle timeouts, and compose pipelines—useful for deployments, server automation, and remote task orchestration.
exec()/shell_exec() calls. Reduces boilerplate for repeated SSH operations (e.g., file transfers, command execution, tunneling)..env).phpseclib may offer more features). Lacks Laravel-specific integrations (e.g., no Eloquent models or Scout compatibility).phpseclib as a fallback for missing features).SSH::run('command')) for consistency.ssh:deploy job) using Laravel Queues.Server::deploy() → SSH commands).libssh).pcntl_fork).phpseclib (async-capable) or Symfony Process Component.Handler integration). Custom error mapping may be needed.Mockery or Laravel’s HTTP tests for simulated SSH servers).encryption or AWS Secrets Manager)?phpseclib (more features, async) or Symfony Process (simpler) instead?Monolog) and alerting (e.g., Slack notifications)?phpseclib or libssh2 (if not bundled). May need Composer updates.cache (for SSH session reuse) or filesystem (for key management).php artisan ssh:backup).ssh->exec('ls -la')) in a Laravel controller.exec() or phpseclib.AppServiceProvider.
$this->app->singleton('ssh', function () {
return new \Herzult\SSH\Client('user@host', 22);
});
SSH facade for cleaner syntax.config/ssh.php (e.g., hosts => ['prod', 'staging']).ShouldQueue (e.g., DeployServerJob).SSHExecuted events for observables.Laravel SSH Mock (if available) or VCR for recording SSH responses.illuminate/support polyfills.ssh->exec()).ssh->put(), ssh->get()).Down events).herzult/php-ssh:dev-master).libssh vulnerabilities). Plan for manual patches or alternative libraries.ssh->setLogLevel(SSH::LOG_DEBUG)).tcpdump or Wireshark to inspect SSH traffic if issues arise.ssh->setTimeout(30).~/.ssh/config or Laravel’s config matches.600 permissions.phpseclib as a backup plan.$ssh = new \Herzult\SSH\Client('user@host');
$ssh->exec('command1');
$ssh->exec('command2'); // Reuses connection
afterCommit() to prevent SSH storms.How can I help you explore Laravel packages today?