Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 

README.md

PHP SSH2

Wrapper class for PHP's SSH2 extension. The base class was created by Jamie Munro taken from this article.

Installation

$ composer require lodev09/php-ssh2

Usage

// connect
$auth = new \SSH2\Password(SFTP_USER, SFTP_PASSWORD);
$sftp = new \SSH2\SFTP(SFTP_HOST, $auth);

if ($sftp->is_connected() && $sftp->is_authenticated()) {
    // upload
    $sftp->put('/path/to/my/local/file', '/remote/file');

    // download
    $sftp->get('/remote/file', '/local/destination/file');
}

SFTP

Common helper methods includes:

  • SFTP::mv - move remote file
  • SFTP::rm - delete remote file
  • SFTP::list - list remote files
  • SFTP::is_dir - check if path is a directory
  • SFTP::exists - check if path exists

Other native methods can be called as well for example:

// ssh2_sftp_mkdir
$sftp->mkdir(...);

SCP

Just a pure wrapper of the native ssh2_scp_xxx functions.

// ssh2_scp_recv
$scp->recv(...);

Feedback

All bugs, feature requests, pull requests, feedback, etc., are welcome. Visit my site at www.lodev09.com or email me at lodev09@gmail.com

Credits

License

Released under the MIT License. See LICENSE file.

You can’t perform that action at this time.