lotfio / pssh
easier php ssh
dev-master
2021-01-23 13:37 UTC
Requires
- php: >=7.4
- ext-ssh2: *
Requires (Dev)
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-12-23 22:30:52 UTC
README
🔑 easier php ssh 🔑
🔥 Introduction :
introduction
📌 Requirements :
- SSH2 extension
- PHP 7.2 or newer versions
- PHPUnit >= 8 (for testing purpose)
🚀 Installation & Use :
composer require lotfio/pssh
✏️ SSH:
<?php // basic usage example require 'vendor/autoload.php'; $config = [ 'host' => 'my-host', 'auth' => new Pssh\Auth\AuthUserPass('lotfio', 'secret') ]; $ssh = new Pssh\Pssh($config); echo $ssh->exec("date"); // Sat Nov 14 08:10:20 PM CET 2020
⚙️ confguration:
- config keys
// additional details $config = [ 'host' => 'server host', 'port' => 'server port || default 22', 'auth' => 'authentication method: AuthUserPass, AuthKeys, AuthHostBasedFile, AuthAgent or AuthNone.', 'timeout' => 'timeout when trying to connect', 'methods' => 'connection method checkout ssh2_connect form more details' 'callbacks' => 'connection callbacks checkout ssh2_connect form more details' ];
- available SSH methods:
$ssh->exec(string $command): string
execute a shell command.$ssh->fingerprint(int $type): string
get connection finger print.$ssh->methodsNegotiated(): array
return an array of negotiated methods.$ssh->addPublicKey(): bool
add a public key.$ssh->removePublicKey(): bool
remove public key.$ssh->listPublicKeys(): array
list public keys.$ssh->tunnel(): resource
open an ssh tunnel.
✏️ SFTP:
<?php require 'vendor/autoload.php'; $config = [ 'host' => 'my-host', 'auth' => new Pssh\Auth\AuthUserPass('lotfio', 'secret') ]; $ssh = new Pssh\Pssh($config); $sftp = new Pssh\Psftp($ssh); $sftp->copyToServer('local-file', 'remote-file');
- available SSH methods:
$sftp->copyToServer(): bool
copy a file from local to remote server.$sftp->copyFromServer(): bool
copy a file from remote server to local.$sftp->chmod(): bool
change mod file or dir.$sftp->mkdir(): bool
make directory.$sftp->rmdir(): bool
remove directory.$sftp->symlink(): bool
create a symlink.$sftp->symlinkTarget(): string
read symlink target.$sftp->symlinkStat(): array
stating a symlink.$sftp->realpath(): string
get realpath.$sftp->rename(): bool
rename file.$sftp->stat(): array
get file stat.$sftp->unlink(): bool
delete file.
💻 Contributing
- Thank you for considering to contribute to Package. All the contribution guidelines are mentioned here.
📃 ChangeLog
- Here you can find the ChangeLog.
🍺 Support the development
- Share Package and lets get more stars and more contributors.
- If this project helped you reduce time to develop, you can give me a cup of coffee :) : Paypal. 💖
📋 License
- Package is an open-source software licensed under the MIT license.