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)27.9k↓36.1%[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 1mo 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

25

—

LowBetter than 37% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity36

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

516d 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

[hannesvdvreken/guzzle-debugbar

A Guzzle middleware that logs requests to debugbar's timeline

76410.4k1](/packages/hannesvdvreken-guzzle-debugbar)

PHPackages © 2026

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