PHPackages                             merlinthemagic/mtm-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. merlinthemagic/mtm-ssh

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

merlinthemagic/mtm-ssh
======================

SSH shell tools for PHP 7

025[1 issues](https://github.com/merlinthemagic/MTM-SSH/issues)PHP

Since Mar 22Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/merlinthemagic/MTM-SSH)[ Packagist](https://packagist.org/packages/merlinthemagic/mtm-ssh)[ RSS](/packages/merlinthemagic-mtm-ssh/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

MTM-SSH
=======

[](#mtm-ssh)

### What is this?

[](#what-is-this)

Make SSH connections to other hosts and issue commands to the shell. You can also connect to one device and use that to connect to another. e.g. ssh to a linux server, use that shell to connect to a routerOS device. Then use the second device to connect to a third device (linux or routeros) and so on

You can execute any command you want. There is full parity with the underlying shells

Install:
--------

[](#install)

```
composer require merlinthemagic/mtm-ssh

```

#### Get a remote shell on a linux server using password

[](#get-a-remote-shell-on-a-linux-server-using-password)

```
$ctrlObj	= \MTM\SSH\Factories::getShells()->passwordAuthentication("IpAddress", "username", "password");

```

#### Get a remote shell on a device running mikrotik routeros using password

[](#get-a-remote-shell-on-a-device-running-mikrotik-routeros-using-password)

```
$username	= \MTM\SSH\Factories::getShells()->getRouterOsTool()->getFormattedUsername("username");
$ctrlObj	= \MTM\SSH\Factories::getShells()->passwordAuthentication("IpAddress", $username, "password");

```

#### Get a remote shell on a linux server using public key authentication

[](#get-a-remote-shell-on-a-linux-server-using-public-key-authentication)

```
$key		= "-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgk.....
....S8dBQ==
-----END PRIVATE KEY-----";

$ctrlObj	= \MTM\SSH\Factories::getShells()->keyAuthentication("IpAddress", "username", $key);

```

#### Get a remote shell on a device running mikrotik routeros using public key authentication

[](#get-a-remote-shell-on-a-device-running-mikrotik-routeros-using-public-key-authentication)

```
$key		= "-----BEGIN PRIVATE KEY-----
MIIEvAIBBDANBgk.....
....S8dBQ==
-----END PRIVATE KEY-----";
$username	= \MTM\SSH\Factories::getShells()->getRouterOsTool()->getFormattedUsername("username");
$ctrlObj	= \MTM\SSH\Factories::getShells()->keyAuthentication("IpAddress", $username, $key);

```

#### Get a remote shell on a linux server using an existing shell

[](#get-a-remote-shell-on-a-linux-server-using-an-existing-shell)

```
//no public key auth yet
$ctrlObj2	= \MTM\SSH\Factories::getShells()->passwordAuthentication("IpAddress", "username", "password", $ctrlObj);
//NOTE: Both existing shell ($ctrlObj) and built on shell ($ctrlObj2) will execute on the second host

```

#### Get a remote shell on a device running mikrotik routeros using an existing shell

[](#get-a-remote-shell-on-a-device-running-mikrotik-routeros-using-an-existing-shell)

```
//no public key auth yet
$username	= \MTM\SSH\Factories::getShells()->getRouterOsTool()->getFormattedUsername("username");
$ctrlObj2	= \MTM\SSH\Factories::getShells()->passwordAuthentication("IpAddress", $username, "password", $ctrlObj);
//NOTE: Both existing shell ($ctrlObj) and built on shell ($ctrlObj2) will execute on the second host

```

#### Start running commands: linux

[](#start-running-commands-linux)

```
$data		= $ctrlObj->getCmd("whoami")->exec()->get();
echo $data; //the name of the user you connected with

$ctrlObj->getCmd("cd /var")->exec()->get();
$data		= $ctrlObj->getCmd("ls -sho --color=none")->exec()->get();
echo $data; //directory and file listing from /var

```

#### Start running commands: routeros

[](#start-running-commands-routeros)

NOTE: Disable all echo logging on the device or return might get corrupted if a log message echos into the shell while running a command

```
$data		= $ctrlObj->getCmd("/system resource print")->exec()->get();
echo $data; //list of system resources

$data		= $ctrlObj->getCmd("/interface print")->exec()->get();
echo $data; //list of interfaces

```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance54

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity12

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8021715?v=4)[Martin Peter Madsen](/maintainers/merlinthemagic)[@merlinthemagic](https://github.com/merlinthemagic)

---

Top Contributors

[![merlinthemagic](https://avatars.githubusercontent.com/u/8021715?v=4)](https://github.com/merlinthemagic "merlinthemagic (18 commits)")

### Embed Badge

![Health badge](/badges/merlinthemagic-mtm-ssh/health.svg)

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

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25025.5M80](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.2M6.6k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k20.0k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87930.4k113](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.3M84](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69122.6k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

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