PHPackages                             faraweilyas/sshbunny - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. faraweilyas/sshbunny

ActiveLibrary[CLI &amp; Console](/categories/cli)

faraweilyas/sshbunny
====================

PHP library that provides an object-oriented wrapper to connect to SSH and run shell commands with the php ssh2 extension.

v1.0.4(7y ago)583MITPHP

Since Nov 24Pushed 7y ago2 watchersCompare

[ Source](https://github.com/faraweilyas/sshbunny)[ Packagist](https://packagist.org/packages/faraweilyas/sshbunny)[ Docs](https://github.com/faraweilyas/sshbunny)[ RSS](/packages/faraweilyas-sshbunny/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (6)Used By (0)

sshbunny
========

[](#sshbunny)

PHP library that provides an object-oriented wrapper to connect to SSH and run shell commands with the php ssh2 extension.

Requirements
============

[](#requirements)

---

- PHP version 5.3+
- [SSH2 extension](http://www.php.net/manual/en/book.ssh2.php).
- [composer](http://getcomposer.org).

Install with composer
=====================

[](#install-with-composer)

---

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

```
composer require faraweilyas/sshbunny
```

or

Clone this repo
===============

[](#clone-this-repo)

```
git clone https://github.com/faraweilyas/sshbunny.git
```

Configuration
=============

[](#configuration)

---

`SSHBunny` constructor takes four parameters and they all have default values `$method='local'`, `$authType=NULL`, `$host=NULL`, `$port=22`, `$username=NULL`

- `$method` can be set to `local` or `remote`, `local` will execute commands on your own shell without internet connection while `remote` executes commands on the remote server that you connect to based on your configuration.
- `$authType` can be set to `KEY`, `PASSWORD` or `KEY_PASSWORD`, `KEY` and `KEY_PASSWORD` uses [ssh2\_auth\_pubkey\_file](http://php.net/manual/en/function.ssh2-auth-pubkey-file.php) the difference is when you set `$authType='KEY_PASSWORD'` ssh2\_auth\_pubkey\_file takes the last parameter of password which will now be required and `PASSWORD` uses [ssh2\_auth\_password](http://php.net/manual/en/function.ssh2-auth-password.php).
- `$port` should be set to your server port if your are connecting to a remote server.
- `$username` should be set to your server username.

if your are setting connection method to `$method='remote'` and `$authType = KEY || KEY_PASSWORD` that means you will need to set your public &amp; private key file which you can do with the setters `SSHBunny` has `$sshBunny->setKeys('public_key.pub', 'private_key')` before initialization.

Basic usage
===========

[](#basic-usage)

---

This is just going to run locally since connection method is set to `local`

```
