PHPackages                             sandeshjangam/tiny-ssh-php - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. sandeshjangam/tiny-ssh-php

ActiveLibrary[HTTP &amp; Networking](/categories/http)

sandeshjangam/tiny-ssh-php
==========================

Tiny SSH package that allows you to execute commands over SSH connections.

v1.1.0(1y ago)29.9k↓57.7%[2 issues](https://github.com/sandeshjangam/tiny-ssh-php/issues)MITPHPPHP &gt;=7.1

Since Oct 10Pushed 1y ago2 watchersCompare

[ Source](https://github.com/sandeshjangam/tiny-ssh-php)[ Packagist](https://packagist.org/packages/sandeshjangam/tiny-ssh-php)[ RSS](/packages/sandeshjangam-tiny-ssh-php/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

Tiny SSH PHP
============

[](#tiny-ssh-php)

Tiny SSH package that allows you to execute commands over SSH connections. It supports both password and private key authentication and is built on the [phpseclib](https://phpseclib.com/) library.

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

[](#installation)

Install the package via composer:

```
composer require sandeshjangam/tiny-ssh-php
```

Usage
-----

[](#usage)

Simple SSH command using password authentication:

```
$ssh = (new Ssh)
    ->host($ip)
    ->port(22)
    ->user($user)
    ->password($password)
    // ->privateKey($privateKey)
    // ->privateKeyPath($privateKeyPath)
    ->connect();

$response = $ssh->execute('whoami');

$response->getOutput();  // 'username'
$response->getError();   // ''
```

### Response of a command

[](#response-of-a-command)

Get the output:

```
$response->getOutput(); // It returns the `stdout`
```

Get the error if any:

```
$response->getError(); // It returns the `stderr`
```

Get the exit status:

```
$response->getExitStatus(); // 0 for success. To check if the command ran successfully
```

### Running multiple commands

[](#running-multiple-commands)

To execute multiple commands pass an array of commands:

```
$response = $ssh->execute(['whoami', 'ls -la']);
```

Or pass the commands as a string separated by `&&`:

```
$response = $ssh->execute('whoami && ls -la');
```

### Use timeout for the long running command

[](#use-timeout-for-the-long-running-command)

You can set the `timeout`. Default is 10 seconds:

```
->timeout(60) // 60 seconds
```

### Use private key as a string or file

[](#use-private-key-as-a-string-or-file)

You can use `Private Key` content:

```
->privateKey('private_key_content')
```

Or `Private Key` file path:

```
->privateKeyPath('/home/user/.ssh/id_rsa')
```

### Upload or Download files and directories

[](#upload-or-download-files-and-directories)

To upload or download files and directories, you'll need to use the SFTP class:

```
$sftp = (new Sftp)
    ->host($ip)
    ->port(22)
    ->user($user)
    ->password($password)
    // ->privateKey($privateKey)
    // ->privateKeyPath($privateKeyPath)
    ->connect();
```

To `upload` a file or directory to the remote server:

```
$sftp->upload('local/file/path', 'remote/file/path')
```

To `download` a file or directory from the remote server:

```
$sftp->download('remote/file/path', 'local/file/path')
```

### Disconnect SSH or SFTP connection

[](#disconnect-ssh-or-sftp-connection)

To disconnect the SSH connection:

```
$ssh->disconnect();
```

To disconnect the SFTP connection:

```
$sftp->disconnect();
```

Testing
-------

[](#testing)

```
composer test
```

Credits
-------

[](#credits)

- [phpseclib](https://phpseclib.com/)
- [PHP SSH Connection](https://github.com/DivineOmega/php-ssh-connection)

License
-------

[](#license)

The [MIT License (MIT)](LICENSE.md).

###  Health Score

24

—

LowBetter than 30% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~34 days

Total

3

Last Release

607d ago

Major Versions

v0.0.1 → v1.0.02024-12-04

### Community

Maintainers

![](https://www.gravatar.com/avatar/647e39c4b12baa4e3d92e8962db16a0bd5fd9f0972833bb5ce165588859b8788?d=identicon)[sandeshjangam](/maintainers/sandeshjangam)

---

Top Contributors

[![sandeshjangam](https://avatars.githubusercontent.com/u/15683894?v=4)](https://github.com/sandeshjangam "sandeshjangam (5 commits)")

---

Tags

phpphpseclibsshphpsshphpseclib

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/sandeshjangam-tiny-ssh-php/health.svg)

```
[![Health](https://phpackages.com/badges/sandeshjangam-tiny-ssh-php/health.svg)](https://phpackages.com/packages/sandeshjangam-tiny-ssh-php)
```

###  Alternatives

[leantime/leantime

Open source project management system for non-project managers. Simple like Trello, powerful like Jira. Built with neurodiversity in mind.

11.3k4.0k](/packages/leantime-leantime)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

762297.9k53](/packages/civicrm-civicrm-core)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.8M672](/packages/shopware-core)[egroupware/egroupware

EGroupware extends a classic groupware with an integrated CRM-system, a secure file-server and Collabora Online Office.

2951.7k](/packages/egroupware-egroupware)[n1ebieski/ksef-php-client

PHP API client that allows you to interact with the API Krajowego Systemu e-Faktur

9082.3k](/packages/n1ebieski-ksef-php-client)[aspose-cloud/aspose-words-cloud

Open, generate, edit, split, merge, compare and convert Word documents. Integrate Cloud API into your solutions to manipulate documents. Convert PDF to Word (DOC, DOCX, ODT, RTF and HTML) and in the opposite direction.

33182.7k](/packages/aspose-cloud-aspose-words-cloud)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
