https://github.com/lodev09/php-ssh2
Wrapper class for PHP's SSH2 extension.
https://github.com/lodev09/php-ssh2
php-library php-ssh2 scp ssh2
Last synced: 2 months ago
JSON representation
Wrapper class for PHP's SSH2 extension.
- Host: GitHub
- URL: https://github.com/lodev09/php-ssh2
- Owner: lodev09
- License: mit
- Created: 2018-10-05T19:16:29.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-02-16T18:31:43.000Z (about 4 years ago)
- Last Synced: 2025-10-04T16:45:22.802Z (6 months ago)
- Topics: php-library, php-ssh2, scp, ssh2
- Language: PHP
- Homepage: https://github.com/lodev09/php-ssh2
- Size: 6.84 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
PHP SSH2
============================
Wrapper class for PHP's [SSH2 extension](http://php.net/manual/en/book.ssh2.php). The base class was created by [Jamie Munro](https://www.sitepoint.com/author/jmunro/) taken from [this article](https://www.sitepoint.com/using-ssh-and-sftp-with-php/).
## Installation
```term
$ composer require lodev09/php-ssh2
```
## Usage
```php
// 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:
```php
// ssh2_sftp_mkdir
$sftp->mkdir(...);
```
### SCP
Just a pure wrapper of the native `ssh2_scp_xxx` functions.
```php
// ssh2_scp_recv
$scp->recv(...);
```
## Feedback
All bugs, feature requests, pull requests, feedback, etc., are welcome. Visit my site at [www.lodev09.com](http://www.lodev09.com "www.lodev09.com") or email me at [lodev09@gmail.com](mailto:lodev09@gmail.com)
## Credits
- [Jamie Munro](https://www.sitepoint.com/author/jmunro/)
- Jovanni Lo [@lodev09](http://twitter.com/lodev09)
## License
Released under the [MIT License](http://opensource.org/licenses/MIT).
See [LICENSE](LICENSE) file.