degagne/libssh2

PHP SSH2 wrapper library

v1.2.0 2018-01-24 18:57 UTC

This package is not auto-updated.

Last update: 2024-10-27 06:18:17 UTC


README

Latest Stable Version Latest Unstable Version License composer.lock Scrutinizer Code Quality Build Status Code Intelligence Status

LibSSH2 implements all supported SSH2 functions from the libssh2 extension.

Requirements

  • PHP >= 5.4
  • libssh2 Extension

Installation

Add libssh2 package to your composer.json file.

{
    "require": {
        "degagne/libssh2": "~1.2.1"
    }
}

or run composer require degagne/libssh2

Usage

$configuration = (new Configuration())
    ->set_username('username')
    ->set_password('password')
    ->set_host('hostname');

$authentication = new Password($configuration);

$ssh = new SSH($configuration, $authentication);
$ssh->exec('ls -ltr');

$output = $ssh->get_output();     // stdout
$errors = $ssh->get_error();      // stderr
$retval = $ssh->get_exitstatus(); // return code

With Kerberos:

$kerberos = new Kerberos($configuration, $authentication);
$krb_cache = $kerberos->kcreate('principle');

$ssh->exec("export KRBCCNAME={$krb_cache};ls -ltr");

Kerberos requires the use of the KRBCCNAME environmental variable to be set.