Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/Herzult/php-ssh

An experimental object oriented SSH api in PHP
https://github.com/Herzult/php-ssh

Last synced: 10 days ago
JSON representation

An experimental object oriented SSH api in PHP

Awesome Lists containing this project

README

        

PHP SSH
=======

[![Build Status](https://travis-ci.org/Herzult/php-ssh.png?branch=master)](https://travis-ci.org/Herzult/php-ssh) (master)

Provides an object-oriented wrapper for the php ssh2 extension.

Requirements
------------

You need PHP version 5.3+ with the [SSH2 extension](http://www.php.net/manual/en/book.ssh2.php).

Installation
------------

The best way to add the library to your project is using [composer](http://getcomposer.org).

$ composer require herzult/php-ssh:~1.0

Usage
-----

### Configuration of the connection

To establish an SSH connection, you must first define its configuration.
For that, create a Configuration instance with all the needed parameters.

```php
getAuthentication('optional_passphrase', 'optional_username');
```

### Create a session

The session is the central access point to the SSH functionality provided by the library.

```php
getAuthentication());
```

This will pick up your public and private keys from your config file Host and Identity declarations.

### Subsystems

Once you are authenticated over a SSH session, you can use the subsystems.

#### Sftp

You can easily access the sftp subsystem of a session using the `getSftp()` method:

```php
getSftp();
```

See the `Ssh\Sftp` class for more details on the available methods.

#### Publickey

The session also provides the `getPublickey()` method to access the publickey subsystem:

```php
getPublickey();
```

See the `Ssh\Publickey` class for more details on the available methods.

#### Exec

The session provides the `getExec()` method to access the exec subsystem

```php
getExec();

echo $exec->run('ls -lah');
```

See the `Ssh\Exec` class for more details.