sevencoder / ssh-connect
SSH连接库
v0.0.1-alpha
2023-10-15 17:07 UTC
Requires
- php: >=7.0, <8.2
Requires (Dev)
- phpunit/phpunit: ^9.6
This package is not auto-updated.
Last update: 2024-09-30 18:50:18 UTC
README
使用PHP和SSH2库简单管理SSH连接
安装
要安装此依赖项,请执行以下注释。
composer require sevencoder/ssh-connect
使用方法
要使用此库,请参考以下示例
<?php require __DIR__.'/vendor/autoload.php'; //Dependency use SevenCoder\SecureShell\SSH; //Instance $connectionSSH = new SSH; $host = '127.0.0.1'; $port = '2222'; //Connection if(!$connectionSSH->connect($host, $port)) { die('Conection Fail'); } //Authentication with user && password if($connectionSSH->authPassword('user','password')) { die('Athentication Fail'); } //Authentication with pair keys if($connectionSSH->authPublicKeyFile('user', 'id_rsa.pub', 'id_rsa.pem')) { die('Athentication Fail'); } //Execute Comands $stdIo = $connectionSSH->exec('ls -l', $stdErr); echo "STDERR:\n".$stdErr; echo "STDIO:\n".$stdIo;
需求
- PHP 7.0
- lib SSH2