PHPackages                             jord-jd/php-ssh-connection - 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. jord-jd/php-ssh-connection

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

jord-jd/php-ssh-connection
==========================

Provides an elegant syntax to connect to SSH servers and execute commands.

v4.0.0(2mo ago)11218211LGPL-3.0-onlyPHPPHP &gt;=7.2CI passing

Since Jul 31Pushed 2mo agoCompare

[ Source](https://github.com/Jord-JD/php-ssh-connection)[ Packagist](https://packagist.org/packages/jord-jd/php-ssh-connection)[ GitHub Sponsors](https://github.com/DivineOmega)[ RSS](/packages/jord-jd-php-ssh-connection/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (12)Used By (1)

PHP SSH Connection
==================

[](#php-ssh-connection)

[![Tests](https://github.com/Jord-JD/php-ssh-connection/actions/workflows/tests.yml/badge.svg)](https://github.com/Jord-JD/php-ssh-connection/actions/workflows/tests.yml)

The PHP SSH Connection package provides an elegant syntax to connect to SSH servers and execute commands. It supports password and public-private key authentication, and can capture command output and errors.

Supported runtimes: PHP 7.2+ and PHP 8.x.

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

[](#installation)

Install with Composer:

```
composer require jord-jd/php-ssh-connection
```

Usage
-----

[](#usage)

```
$connection = (new SSHConnection())
            ->to('test.rebex.net')
            ->onPort(22)
            ->as('demo')
            ->withPassword('password')
         // ->withPrivateKey($privateKeyPath)
         // ->withPrivateKeyString($privateKeyContents)
         // ->timeout(30)
            ->connect();

$command = $connection->run('echo "Hello world!"');

$command->getOutput();  // 'Hello world!'
$command->getError();   // ''

$connection->upload($localPath, $remotePath);
$connection->download($remotePath, $localPath); // supports recursive directory downloads
```

### Running multiple commands

[](#running-multiple-commands)

Each `run()` call executes in a fresh shell context. If you need stateful command execution (for example `cd` then `touch`), use `runCommands()`:

```
$connection->runCommands([
    'cd /var/www/html',
    'mkdir -p app',
    'cd app',
    'touch index.php',
]);
```

### Fingerprint verification

[](#fingerprint-verification)

For security, you can fingerprint the remote server and verify it remains the same across connections.

```
$fingerprint = $connection->fingerprint(); // defaults to MD5 for backward compatibility

if ($newConnection->fingerprint() !== $fingerprint) {
    throw new Exception('Fingerprint does not match!');
}
```

Available fingerprint types:

```
$md5Fingerprint    = $connection->fingerprint(SSHConnection::FINGERPRINT_MD5);
$sha1Fingerprint   = $connection->fingerprint(SSHConnection::FINGERPRINT_SHA1);
$sha256Fingerprint = $connection->fingerprint(SSHConnection::FINGERPRINT_SHA256);
$sha512Fingerprint = $connection->fingerprint(SSHConnection::FINGERPRINT_SHA512);
```

Testing
-------

[](#testing)

The package test suite includes SSH integration tests. Set these variables before running tests:

- `RUN_SSH_INTEGRATION_TESTS=1`
- `SSH_TEST_HOST`
- `SSH_TEST_PORT`
- `SSH_TEST_USER`
- `SSH_TEST_PRIVATE_KEY_PATH` or `SSH_TEST_PRIVATE_KEY_CONTENTS`
- `SSH_TEST_PASSWORD` (only required for password-auth test)

Then run:

```
vendor/bin/phpunit
```

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance84

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 91.4% 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 ~239 days

Recently: every ~596 days

Total

11

Last Release

83d ago

Major Versions

v1.3.1 → v2.0.02019-08-08

v2.2.0 → v3.0.02026-02-14

v3.0.0 → v4.0.02026-02-16

PHP version history (2 changes)v1.0.0PHP &gt;=7.1

v4.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/c580cdf7c14898fff179cdfc1085892091d5d2f49d917873a12365af9ac77c93?d=identicon)[Jord-JD](/maintainers/Jord-JD)

---

Top Contributors

[![Jord-JD](https://avatars.githubusercontent.com/u/650645?v=4)](https://github.com/Jord-JD "Jord-JD (64 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (2 commits)")[![sboesch](https://avatars.githubusercontent.com/u/16945695?v=4)](https://github.com/sboesch "sboesch (2 commits)")[![EdwinHoksberg](https://avatars.githubusercontent.com/u/6866019?v=4)](https://github.com/EdwinHoksberg "EdwinHoksberg (1 commits)")[![sonaldo](https://avatars.githubusercontent.com/u/3761019?v=4)](https://github.com/sonaldo "sonaldo (1 commits)")

---

Tags

phpsshssh-clientssh-client-library

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jord-jd-php-ssh-connection/health.svg)

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

###  Alternatives

[hyperwallet/sdk

A library to manage users, transfer methods and payments through the Hyperwallet API

12532.1k2](/packages/hyperwallet-sdk)[highsidelabs/walmart-api

A PHP client for Walmart's Marketplace, 1P Supplier, and Content Provider APIs.

308.0k](/packages/highsidelabs-walmart-api)

PHPackages © 2026

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