Giter VIP home page Giter VIP logo

php7-sshwrapper's Introduction

PHP7-SSHWrapper

Friendly wrapper for the amazing PHPSECLIB SSHv2 implementation Forked from metaclassing/php7-sshwrapper to update phpseclib version.

SIMPLE example usage:

# more test.php
<?php
// run: composer require metaclassing/php7-sshwrapper:dev-master
require_once('vendor/autoload.php');

// Some information for how to connect to the device
$deviceinfo = [
    'host'     => '204.123.456.789',
    'username' => 'awesomeUsername',
    'password' => 'SecretP4ssW@rd'
];

// My wrapper throws exceptions, even though phpseclibv2 does not
try {
    // Create a ssh object with our device information
    $sshwrapper = new Metaclassing\SSH( $deviceinfo );

    // order the wrapper to attempt to connect
    // my wrapper has all that handy network device prompt regex logic added!
    $sshwrapper->connect();

    // send the term len 0 command to stop paging output with ---more---
    $sshwrapper->exec('terminal length 0');

    // send an actual command we want the output from
    $command = 'show version';
    $output = $sshwrapper->exec($command);
    echo $output . PHP_EOL;

// catch any exceptions with helpful error hunting
} catch (\Exception $e) {
    echo 'Encountered exception: ' . $e->getMessage() . PHP_EOL;
}

Which when run should result in some output like:

# php test.php
show version
Cisco IOS Software, 3700 Software (C3745-ADVENTERPRISEK9-M), Version 12.4(15)T12, RELEASE SOFTWARE (fc3)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2010 by Cisco Systems, Inc.
Compiled Fri 22-Jan-10 04:24 by prod_rel_team

ROM: System Bootstrap, Version 12.4(13r)T5, RELEASE SOFTWARE (fc1)

LAX-R3745 uptime is 4 years, 14 weeks, 3 days, 21 hours, 31 minutes
System returned to ROM by reload at 19:33:30 CDT Mon Aug 19 2013
System restarted at 19:34:55 CDT Mon Aug 19 2013
System image file is "flash:c3745-adventerprisek9-mz.124-15.T12.bin"

Cisco 3745 (R7000) processor (revision 2.0) with 184320K/77824K bytes of memory.
Processor board ID JMX0804L2Y6
R7000 CPU at 350MHz, Implementation 39, Rev 3.3, 256KB L2, 2048KB L3 Cache
2 FastEthernet interfaces
1 Virtual Private Network (VPN) Module
DRAM configuration is 64 bits wide with parity disabled.
151K bytes of NVRAM.
125440K bytes of ATA System CompactFlash (Read/Write)

Configuration register is 0x2102

LAX-R3745#

php7-sshwrapper's People

Contributors

metaclassing avatar ohtarr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.