定制 wiardvanrij/sshwrapper 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

wiardvanrij/sshwrapper

Composer 安装命令:

composer require wiardvanrij/sshwrapper

包简介

SSH wrapper for PHP

README 文档

README

Information

!!! This is in very beta. I would not recommend using this on production or whatsoever. !!!

This library allows you to connect via SSH to your linux server with the PHP core class 'ssh2'. It also allows to use a "jump server" for instance:

command --ssh to-> jump server --ssh to-> actual server

Requirements

You will need to install the PHP ssh2 extension and enable this. I assume you have knowledge on how to install php extensions

Installation

Via composer

{
    "require": {
        "wiardvanrij/sshwrapper": "*"
    }
}

Because this library is in beta, please use the latest version. There is no stable

Usage

Require the autoloader and include the namespace

<?php

require('vendor/autoload.php');

use SshWrapper\SshCore;

Initiate the class with the host

$ssh = new SshCore('123.123.123.123');

Optional: Define the rsa public and private key locations if they differ from default. Defaults:

$ssh->authPriv = '~/.ssh/id_rsa';
$ssh->authPub = '~/.ssh/id_rsa.pub';

Optional: Define user and port if they differ from the default. Defaults:

$ssh->authUser = 'root';
$ssh->port = 22;

Prefered: If you use the ssh server as "jump server" you can define the actual server here including the user.

$ssh->jumphost = 'root@321.321.321.321';

Connect

$ssh->connect();

And execute a command

$result = $ssh->exec('ls -lah');

var_dump($result);

Result is a string of the output

Disconnect to close the ssh connection

$ssh->disconnect();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-10-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固