Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Herzult/php-ssh
An experimental object oriented SSH api in PHP
https://github.com/Herzult/php-ssh
Last synced: about 1 month ago
JSON representation
An experimental object oriented SSH api in PHP
- Host: GitHub
- URL: https://github.com/Herzult/php-ssh
- Owner: Herzult
- License: mit
- Created: 2011-03-27T18:02:01.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2023-05-11T20:27:20.000Z (over 1 year ago)
- Last Synced: 2024-05-06T07:34:06.133Z (7 months ago)
- Language: PHP
- Homepage:
- Size: 110 KB
- Stars: 358
- Watchers: 22
- Forks: 81
- Open Issues: 27
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this project
- awesome-php - PHP SSH - An experimental object-orientated SSH wrapper library. (Table of Contents / Security)
- awesome-php-cn - PHP SSH - 一个实验对象导向SSH包装器库. (目录 / 安全 Security)
- awesome-projects - PHP SSH - An experimental object orientated SSH wrapper library. (PHP / Security)
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.