paulvl/ssh 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

paulvl/ssh

Composer 安装命令:

composer require paulvl/ssh

包简介

A package to execute commands over an SSH connection using phpseclib

README 文档

README

SSH is a small and functional package that allow the commands execution over an SSH connection using phpseclib.

Quick Installation

Begin by installing this package through Composer.

You can run:

composer require paulvl/ssh

Or edit your project's composer.json file to require paulvl/ssh.

 "require": {
     ...
     "paulvl/ssh": "1	.*"
}

Next, update Composer from the Terminal:

composer update

Once the package's installation completes, you can start using the library to connect to your servers and excutes comands:

/*
create and ssh instance passing:
- server IP
- username
- private key value
- ssh port number
*/
$ssh = new SHH\SSH(
	'your.own.server.ip',
	'username',
	'your-private-key',
	22);

SSH functions

canConnect - Test the connection

To evaluate if the host can be connected with the given parameteres call the canConnect function:

$ssh->canConnect();

This will return true if the connection is successful.

connect - Open the connection to the host

To open the connection with te given parameters call the connect function:

$ssh->connect();

Every timw you want to check the connection status

disconnect - Close the connection to the host

To close the current open connection call the disconnect function:

$ssh->disconnect();

run - Excecutes commands within the current connection

To execute commands on within the current open connection you should pass an array of commands as a parameter calling the run function:

$ssh->run(['command-1', 'command-2']);

You will get and array as result where you can see and unique execution id, the exit status of the executed command, the cli output as result and the duration in milliseconds.

[0] => Array
(
    [id] => 3e75a0e9-3de8-4c57-8a4b-a858af602089
    [status] => true
    [result] => command output message
    [duration] => 0.362
)

Contribute and share ;-)

If you like this little piece of code share it with you friends and feel free to contribute with any improvements.

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固