jzfpost/ssh2

PHP SSH2-client connection helper based on ext-ssh2

Maintainers

Details

github.com/jzfpost/ssh2

Source

Issues

Installs: 3

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:ssh2-helper

v0.5.0-alpha 2022-11-29 18:12 UTC

This package is not auto-updated.

Last update: 2024-04-22 16:55:32 UTC


README

PHP SSH2-client connection helper based on ext-ssh2.

Example usage

$auth = new Password('username', 'password');

$conf = (new Configuration())
    ->setTermType(TermTypeEnum::dumb);
        
$ssh2 = new Ssh($conf, new RealtimeLogger());
$ssh2 = $ssh2->connect('192.168.1.1')
    ->authPassword('jzf', 'Ob$curite_25');
    
if (!$ssh->authenticate()) {
    throw new RuntimeException('Not authorised');
};

//open shell on network device
$shell = $ssh2->getShell()->open(PromptEnum::cisco->value);
$result = $shell->exec('show version');

// or exec on linux
$exec = $ssh2->getExec();
$result = $exec->exec('ls -a');

$ssh2->disconnect();