hexpang/ssh-client

v0.5.3 2016-08-26 19:10 UTC

This package is not auto-updated.

Last update: 2020-08-05 07:43:29 UTC


README

SSH Client for PHP.

Build Status
[Build Status]

Install With Composer

composer require hexpang/ssh-client

Namespace

hexpang\Client\SSHClient

Require

SSH2

Usage

require_once 'path_to/vendor/autoload.php';
use hexpang\Client\SSHClient\SSHClient;
$client = new SSHClient($host,$port,$username,$password);
if($client->ping($host,$port,10)){
  if($client->connect() && $client->authorize()){
    var_dump($client->cmd('ls -l'));
  }else{
    echo "Oops.";
  }  
}else{
  echo "Ping Timeout!";
}

Method

Method Description Usage
ping Check port $ssh->ping($host,$port,$timeOut)
connect Connect to server $ssh->connect()
authorize Authorize $ssh->authorize()
authorizeWithPK Authorize With Public Key $ssh->authorizeWithPK('id_rsa.pub','id_rsa','passphrase')
cmd Execute command and response result for an array[ Response,Error ] $ssh->cmd($command)
scp_send Send file via SCP Protocol $client->scp_send($local_file,$remote_file,$create_mode = 644)
scp_recv Receive file via SCP Protocol $client->scp_recv($remote_file,$local_file)
disconnect Disconnect $ssh->disconnect()