PHP code example of k92 / ssh-exec

1. Go to this page and download the library: Download k92/ssh-exec 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/ */

    

k92 / ssh-exec example snippets


use K92\SshExec\SSHEngine;

$se = (new SSHEngine)
    ->from([
        'ssh_privatekey_path' => '/root/.ssh/id_ed25519', 
    ])
    ->to([
        'ssh_address' => 'localhost',
        'ssh_debug' => true,
        'ssh_port' => 22,
        'ssh_socket_path' => null, // manual disable multiplexing
        'ssh_username' => 'root',
    ])
    ->exec([
        'ls -1 /opt/',
        'touch /opt/newfile'
    ])
    ->exec('ls -1 /opt/')
    ->exec('touch /opt/newfile');

./vendor/bin/phpunit tests