PHP code example of degagne / libssh2

1. Go to this page and download the library: Download degagne/libssh2 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

degagne / libssh2 example snippets


$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

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

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