Skip to content

Instantly share code, notes, and snippets.

View iyut's full-sized avatar

Luthfi Bintoro iyut

View GitHub Profile
@danielbwa
danielbwa / list_and_download_files_through_sftp_with_php.php
Last active December 1, 2024 00:09
List and download all files in a directory through sftp with php / ssh2. In my example i use scandir to list the files and ssh2_scp_recv to grab a file. I've found a lot of examples using fopen to grab the remote file, that didn't work for me and i found the code below cleaner than the fopen option. For an example on how to do the same as my exa…
<?php
$username = "your_username";
$password = "your_pass";
$url = 'your_stp_server_url';
// Make our connection
$connection = ssh2_connect($url);
// Authenticate