PHP code example of tomcan / ssh-tasks

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

    

tomcan / ssh-tasks example snippets



    h = [
        [
            'type' => 'password',
            'password' => 'my-secret-password',
        ],
    ];

    $connection = new \TomCan\SshTasks\SshConnection('myserver.domain.tld', 22, 'myuser', $auth);
    $task = new \TomCan\SshTasks\SshTask($c, 'echo Hello world!');

    var_dump($task->execute());

$auth = [
    ['type' => 'none'],
];

    $callbacks = [
        'output' => function($t) { echo 'out> '.$t; },
        'error' => function($t) { echo 'err> '.$t; },
    ];
    $t->execute(true, 'callback', $callbacks));