meklis / console-client
SSH/Telnet client
Installs: 1 169
Dependents: 2
Suggesters: 0
Security: 0
Stars: 5
Watchers: 1
Forks: 4
Open Issues: 0
Requires
- php: >=7.2.0
- ext-mbstring: *
- ext-sockets: *
- ext-ssh2: *
This package is auto-updated.
Last update: 2024-11-15 21:18:44 UTC
README
PHP library for login/password connections to devices over Telnet and SSH.
Install
composer require meklis/console-client
Example
SSH connection to ZTE devices
require __DIR__ . '/vendor/autoload.php'; $ssh = new \Meklis\Network\Console\SSH(); $ssh->setDeviceHelper(new \Meklis\Network\Console\Helpers\ZTE()); $ssh->connect("10.0.0.2", 2222); //Ip and custom port $ssh->login("login", "password"); echo $ssh->exec("show card");
Telnet connection to Dlink device
require __DIR__ . '/vendor/autoload.php'; $ssh = new \Meklis\Network\Console\Telnet(); $ssh->setDeviceHelper(new \Meklis\Network\Console\Helpers\Dlink()); $ssh->connect("10.0.0.1"); $ssh->login("login", "password"); echo $ssh->exec("show switch");
Supported vendors
- Alcatel
- Alaxala
- Bdcom
- Cdata
- Dlink
- Dell
- Edgecore
- Foxgate
- Gcom
- Huawei
- Tp-link
- Ios
- ZTE
- Junos
- Linux
- Vsolution
- Xos
For adding own vendors you can create Helper extended from DefaultHelper and implement HelperInterface.
Example of helper
namespace Meklis\Network\Console\Helpers; class Cdata extends DefaultHelper { protected $prompt = 'OLT(.*?)[>#]'; protected $userPrompt = 'ame:'; protected $passwordPrompt = 'ord:'; protected $afterLoginCommands = []; protected $beforeLogoutCommands = []; protected $windowSize = null; public function isDoubleLoginPrompt(): bool { if ($this->connectionType === 'ssh') { return true; } return $this->doubleLoginPrompt; } }