PHPackages                             detain/sshwitch - 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. [CLI &amp; Console](/categories/cli)
4. /
5. detain/sshwitch

ActiveLibrary[CLI &amp; Console](/categories/cli)

detain/sshwitch
===============

Login and run commands on your network devices via an ssh connection on a remote server. Easy to use PHP static class methods with static chaining support for rapid development. Supports Cisco and Juniper network routers and switches with more easily added.

v1.0.0(1y ago)11.0kGPL-3.0PHPCI passing

Since Nov 6Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/detain/sshwitch)[ Packagist](https://packagist.org/packages/detain/sshwitch)[ RSS](/packages/detain-sshwitch/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

sshwitch — SSH Switch / Router Helper
=====================================

[](#sshwitch--ssh-switch--router-helper)

[![License: GPL v3](https://camo.githubusercontent.com/48bf9b56d44f38db53ce21294cf0b9487d0a3734ab3ba1fe4c69858ae20db2c1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d47504c76332d626c75652e737667)](https://www.gnu.org/licenses/gpl-3.0)[![PHP Version](https://camo.githubusercontent.com/7bb45bb06ad0e38e8f7acfa86119a274335da649cf68ecadfafdc2845b753757/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545372e34253230253743253743253230253545382e302d3838393242462e737667)](https://www.php.net/)

`sshwitch` is a small PHP library that runs commands on network devices (switches, routers, firewalls) by connecting from a relay box to the device through [RANCID's `clogin`](https://www.shrubbery.net/rancid/) script.

It's built around an all-static, optionally-chainable API that's pleasant to embed in operations scripts — pass a switch IP and a list of commands, get back the parsed per-command output.

`clogin` itself supports a long list of vendors: Cisco, Juniper, Extreme Networks, Procket Networks, Redback, A10, Alteon, Avocent (Cyclades), Bay Networks (Nortel), ADC-kentrox, Foundry, HP, Hitachi, MRV, Mikrotik, Netscreen, Nokia (Alcatel-Lucent), Netscaler, Riverstone, Netopia, Xirrus, Arrcus, and more. This library has been used most heavily against Cisco IOS and Juniper but the transport is identical for any device `clogin` knows.

Table of Contents
-----------------

[](#table-of-contents)

- [Requirements](#requirements)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Configuration](#configuration)
- [How it works](#how-it-works)
- [API Reference](#api-reference)
    - [Methods](#methods)
    - [Properties (via magic accessors)](#properties-via-magic-accessors)
    - [Static chaining](#static-chaining)
- [Examples](#examples)
- [Testing](#testing)
- [Troubleshooting](#troubleshooting)
- [License](#license)

Requirements
------------

[](#requirements)

- **PHP 7.4 or later** (PHP 8.x supported and recommended)
- **`ssh2` PHP extension** — usually packaged as `php-ssh2` / `php8.x-ssh2`
- A **relay/jump host** reachable over SSH that has RANCID's `clogin` script installed at `/usr/libexec/rancid/clogin` (the path is hard-coded in the current version)
- An **SSH keypair** trusted by the relay; the public key file lives at `.pub` next to the private key

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

[](#installation)

Install via Composer:

```
composer require detain/sshwitch
```

Then ensure the `ssh2` extension is loaded:

```
php -m | grep ssh2
```

If it's missing, install it (Debian/Ubuntu: `apt install php-ssh2`).

Quick Start
-----------

[](#quick-start)

```
