PHP code example of lodev09 / php-ssh2
1. Go to this page and download the library: Download lodev09/php-ssh2 library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lodev09 / php-ssh2 example snippets
// 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');
}
// ssh2_sftp_mkdir
$sftp->mkdir(...);
// ssh2_scp_recv
$scp->recv(...);
term
$ composer