edvnetwork/php-ssh
最新稳定版本:2.1
Composer 安装命令:
composer require edvnetwork/php-ssh
包简介
PHP sdk for connect to servers via ssh, sftp an more.
README 文档
README
A PHP sdk for connect to servers via ssh, sftp an more.
Dependencies
- PHP >= 7.4
Setup
If you already have a file, just add the following dependency to your project: composer.json
"require": { "edvnetwork/php-ssh": "^2.1" }
With the dependency added to , just run: composer.json
composer install
Alternatively, you can run directly in your terminal:
composer require edvnetwork/php-ssh
SSH connection with simple user and password authentication
<?php use EDV\net\ssh\SSHConnection; use EDV\net\ssh\auth\SSHPasswordAuthentication; $ssh = new SSHConnection(); $ssh->open('127.0.0.1'); $ssh->authenticate( new SSHPasswordAuthentication('user', 'password')); $directoryIterator = $ssh->getDirectoryIterator('/temp'); while ($directoryIterator->valid()) { $splFileInfo = $directoryIterator->current(); if ($splFileInfo->isFile()) { $splFileObject = $directoryIterator->openFile('r'); } $directoryIterator->next(); }
SSH connection with user's public key
<?php use EDV\net\ssh\SSHConnection; use EDV\net\ssh\auth\SSHPublicKeyAuthentication; $ssh = new SSHConnection(); $ssh->open('example.com'); $ssh->authenticate(new SSHPublicKeyAuthentication('user', '/home/user/.ssh/id_rsa.pub', '/home/user/.ssh/id_rsa', 'passphrase')); $directoryIterator = $ssh->getDirectoryIterator('/temp'); while ($directoryIterator->valid()) { $splFileInfo = $directoryIterator->current(); if ($splFileInfo->isFile()) { $splFileObject = $directoryIterator->openFile('r'); } $directoryIterator->next(); }
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-24