PHPackages                             chris-doehring/ssh - 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. chris-doehring/ssh

Abandoned → [spatie/ssh](/?search=spatie%2Fssh)ArchivedLibrary[HTTP &amp; Networking](/categories/http)

chris-doehring/ssh
==================

A lightweight package to execute commands over an SSH connection, based on `spatie/ssh`, with php 5.6 compatibility.

1.0.0(6y ago)01MITPHPPHP ^5.6.40

Since Feb 21Pushed 6y agoCompare

[ Source](https://github.com/chris-doehring/ssh)[ Packagist](https://packagist.org/packages/chris-doehring/ssh)[ Docs](https://github.com/chris-doehring/ssh)[ Fund](https://spatie.be/open-source/support-us)[ RSS](/packages/chris-doehring-ssh/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

A lightweight package to execute commands over an SSH connection, based on `spatie/ssh`, with php 5.6 compatibility.
====================================================================================================================

[](#a-lightweight-package-to-execute-commands-over-an-ssh-connection-based-on-spatiessh-with-php-56-compatibility)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d071ac4f86ac13560ee5f9a88f0101409324373b0b2d2485a36c16806df747f8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63687269732d646f656872696e672f7373682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/chris-doehring/ssh)[![GitHub Tests Action Status](https://camo.githubusercontent.com/4f980a939a8518eee4f4dd5ad0719b91c7674e4276271fbb86ee2bbad667e2fe/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f63687269732d646f656872696e672f7373682f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/chris-doehring/ssh/actions?query=workflow%3Arun-tests+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/9b77d743c556c953a82a2b934c2f6f3788db2c349e0681f933e1d76acd986d6a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63687269732d646f656872696e672f7373682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/chris-doehring/ssh)

This package is a fork of the original [spatie/ssh](https://github.com/spatie/ssh) package to be compatible with php5.6. *Please use it with caution.*

You can execute an SSH command like this:

```
Ssh::create('user', 'host')->execute('your favorite command');
```

It will return an instance of [Symfony's `Process`](https://symfony.com/doc/3.3/components/process.html).

Support Spatie
--------------

[](#support-spatie)

As Spatie is the original creator of this package, please consider [supporting them](https://spatie.be/open-source/support-us) or checkout another of their great [open source packages](https://spatie.be/open-source).

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

[](#installation)

You can install this package via composer:

```
composer require chris-doehring/ssh
```

Usage
-----

[](#usage)

You can execute an SSH command like this:

```
$process = Ssh::create('user', 'example.com')->execute('your favorite command');
```

It will return an instance of [Symfony's `Process`](https://symfony.com/doc/3.3/components/process.html).

### Getting the result of a command

[](#getting-the-result-of-a-command)

To check if your command ran ok

```
$process->isSuccessful();
```

This is how you can get the output

```
$process->getOutput();
```

### Running multiple commands

[](#running-multiple-commands)

To run multiple commands pass an array to the execute method.

```
$process = Ssh::create('user', 'example.com')->execute([
   'first command',
   'second command',
]);
```

### Choosing a port

[](#choosing-a-port)

You can choose a port by passing it to the constructor.

```
$port = 123;

Ssh::create('user', 'host', $port);
```

Alternatively you can use the `usePort` function:

```
Ssh::create('user', 'host')->usePort($port);
```

### Specifying the private key to use

[](#specifying-the-private-key-to-use)

You can use `usePrivateKey` to specify a path to a private SSH key to use.

```
Ssh::create('user', 'host')->usePrivateKey('/home/user/.ssh/id_rsa');
```

### Disable Strict host key checking

[](#disable-strict-host-key-checking)

By default, strict host key checking is enabled. You can disable strict host key checking using `disableStrictHostKeyChecking`.

```
Ssh::create('user', 'host')->disableStrictHostKeyChecking();
```

### Uploading &amp; downloading files and directories

[](#uploading--downloading-files-and-directories)

You can upload files &amp; directories to a host using:

```
Ssh::create('user', 'host')->upload('path/to/local/file', 'path/to/host/file');
```

Or download them:

```
Ssh::create('user', 'host')->download('path/to/host/file', 'path/to/local/file');
```

Under the hood the process will use `scp`.

### Modifying the Symfony process

[](#modifying-the-symfony-process)

Behind the scenes all commands will be performed using [Symfonys `Process`](https://symfony.com/doc/3.3/components/process.html).

You can configure to the `Process` by using the `configureProcess` method. Here's and example where we disable the timeout.

```
Ssh::create('user', 'host')->configureProcess(fn (Process $process) => $process->setTimeout(null));
```

### Immediately responding to output

[](#immediately-responding-to-output)

You can get notified whenever you command produces output by setting by passing a closure to `onOuput`.

```
Ssh::create('user', 'host')->onOutput(fn($type, $line) => echo $line)->execute('whoami');
```

Whenever there is output that close will get called with two parameters:

- `type`: this can be `Symfony\Component\Process\Process::OUT` for regular output and `Symfony\Component\Process\Process::ERR` for error output
- `line`: the output itself

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

This package has been forked to be compatible with the deprecated php version `5.6`. Please consider using php `7.4` and the most recent original package from [spatie/ssh](https://github.com/spatie/ssh). If you have to use it anyway, be sure to run it on the [security backport version of Microsoft](https://github.com/microsoft/php-src). Neither I nor any other contributors give any warranty when running this fork under php 5.6.

Alternatives
------------

[](#alternatives)

If you need some more features, take a look at [DivineOmega/php-ssh-connection](https://github.com/DivineOmega/php-ssh-connection).

Credits
-------

[](#credits)

This package is completely based on [spatie/ssh](https://github.com/spatie/ssh). If you like it, please consider [supporting them](https://spatie.be/open-source/support-us).

- [Chris Döhring](https://github.com/chris-doehring) (php 5.6 integration)
- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

The `Ssh` class contains code taken from [laravel/envoy](https://laravel.com/docs/6.x/envoy)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55.6% 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

Unknown

Total

1

Last Release

2269d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8f25bd8f4a5f0287916cd551d6d29410527d9fa8a70d1a9f6705ac8d4e4b1a04?d=identicon)[chris-doehring](/maintainers/chris-doehring)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (50 commits)")[![chris-doehring](https://avatars.githubusercontent.com/u/6341536?v=4)](https://github.com/chris-doehring "chris-doehring (8 commits)")[![m1guelpf](https://avatars.githubusercontent.com/u/23558090?v=4)](https://github.com/m1guelpf "m1guelpf (5 commits)")[![rubenvanassche](https://avatars.githubusercontent.com/u/619804?v=4)](https://github.com/rubenvanassche "rubenvanassche (5 commits)")[![mallardduck](https://avatars.githubusercontent.com/u/619938?v=4)](https://github.com/mallardduck "mallardduck (4 commits)")[![zaherg](https://avatars.githubusercontent.com/u/27624?v=4)](https://github.com/zaherg "zaherg (3 commits)")[![mazedlx](https://avatars.githubusercontent.com/u/9453522?v=4)](https://github.com/mazedlx "mazedlx (3 commits)")[![rodelias-frete](https://avatars.githubusercontent.com/u/281798633?v=4)](https://github.com/rodelias-frete "rodelias-frete (3 commits)")[![SamuelNitsche](https://avatars.githubusercontent.com/u/24483576?v=4)](https://github.com/SamuelNitsche "SamuelNitsche (3 commits)")[![MohammedAlkutrani](https://avatars.githubusercontent.com/u/24508555?v=4)](https://github.com/MohammedAlkutrani "MohammedAlkutrani (1 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (1 commits)")[![imliam](https://avatars.githubusercontent.com/u/4326337?v=4)](https://github.com/imliam "imliam (1 commits)")[![localheinz](https://avatars.githubusercontent.com/u/605483?v=4)](https://github.com/localheinz "localheinz (1 commits)")[![chapeupreto](https://avatars.githubusercontent.com/u/834048?v=4)](https://github.com/chapeupreto "chapeupreto (1 commits)")[![michaelaguiar](https://avatars.githubusercontent.com/u/138890?v=4)](https://github.com/michaelaguiar "michaelaguiar (1 commits)")

---

Tags

phpssh5.6

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/chris-doehring-ssh/health.svg)

```
[![Health](https://phpackages.com/badges/chris-doehring-ssh/health.svg)](https://phpackages.com/packages/chris-doehring-ssh)
```

###  Alternatives

[swoole-bundle/swoole-bundle

Open/Swoole Symfony Bundle

6650.4k](/packages/swoole-bundle-swoole-bundle)[pixelfederation/swoole-bundle

Swoole Symfony Bundle

3311.4k](/packages/pixelfederation-swoole-bundle)[abantecart/ups-php

UPS PHP SDK based on OAuth

1815.3k](/packages/abantecart-ups-php)

PHPackages © 2026

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