2017 © Pedro Peláez
 

library ssh2

ssh2 client library

image

zteel/ssh2

ssh2 client library

  • Thursday, March 15, 2018
  • by ftw-soft
  • Repository
  • 2 Watchers
  • 1 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 4 Versions
  • 17 % Grown

The README.md

ssh2

Library which provide you ability execute remote commands like in terminal, (*1)

With this library you can execute any commands using ssh2 protocol., (*2)

Usage

  • Password authentication

<?php use Ssh\Client; use Ssh\Auth\Password; $auth = new Password('username', 'password'); $client = new Client('host_name_or_ip'); try { $client->connect()->authenticate($auth); echo $client->exec('pwd'); } catch (\RuntimeException $e) { echo $e->getMessage(); }
  • Public key authentication

<?php use Ssh\Client; use Ssh\Auth\PublicKey; $auth = new PublicKey('username', 'path to public key', 'path to private key', 'passphrase if set'); $client = new Client('host_name_or_ip'); try { $client->connect()->authenticate($auth); echo $client->exec('pwd'); } catch (\RuntimeException $e) { echo $e->getMessage(); }
  • Command chain

<?php use Ssh\Client; use Ssh\Auth\PublicKey; use Ssh\Command\Result; use Ssh\Command\Chain; $auth = new PublicKey('username', 'path to public key', 'path to private key', 'passphrase if set'); $client = new Client('host_name_or_ip'); try { $client->connect()->authenticate($auth); echo $client ->chain() ->exec('pgrep node', function (Result $result, Chain $chain) { $result = $result->getResult(); if ($result && is_numeric($result)) { $chain->stopChain(); } }) ->exec('/usr/local/bin/node ~/server.js > ~/node_server.log &'); } catch (\RuntimeException $e) { echo $e->getMessage(); }
  • With ssh config file

<?php use Ssh\Config\Configuration; use Ssh\Client; $configuration = new Configuration('path to ssh config file like a /home/username/.ssh/config'); $client = new Client($configuration->getHost('hostname')); // now if you need authenticates with password (PasswordAuthentication set to yes) you need to set password $client->getAuth()->setPassword('xxxxx'); // else if you set IdentityFile or PubkeyAuthentication is yes or not set PubkeyAuthentication // trying to find currenct user public key and private key files into ~/.ssh/ directory, if keys not exists // you need authenticates with methods above, if keys exists you can connect and authenticate try { $client->connect()->authenticate(); echo $client->exec('pwd'); } catch (\RuntimeException $e) { echo $e->getMessage(); }
  • Shell, (*3)

    With shell you can working like in terminal, (*4)


The Versions

15/03 2018

dev-master

9999999-dev https://github.com/Zteel/ssh2

ssh2 client library

  Sources   Download

GPL-2.0-only

The Requires

  • php >=5.4.0

 

ssh ssh2 ssh client

15/03 2018

1.0.2

1.0.2.0 https://github.com/Zteel/ssh2

ssh2 client library

  Sources   Download

GPL-2.0-only

The Requires

  • php >=5.4.0

 

ssh ssh2 ssh client

15/03 2018

1.0.1

1.0.1.0 https://github.com/Zteel/ssh2

ssh2 client library

  Sources   Download

The Requires

  • php >=5.4.0

 

ssh ssh2 ssh client

25/06 2014

dev-develop

dev-develop https://github.com/oncesk/ssh2

ssh2 client library

  Sources   Download

The Requires

  • php >=5.4.0

 

ssh ssh2 ssh client