Example using libssh2:
<?php
$connection = ssh2_connect('tracking.pdi.elanders-germany.com', 22);
ssh2_auth_password($connection, 'USERNAME', 'PASSWORT');
$sftp = ssh2_sftp($connection);
$handle = opendir("ssh2.sftp://$sftp/./");
echo "Directory handle: $handle\n";
echo "Entries:\n";
while (false != ($entry = readdir($handle))){
echo "$entry\n";
}
… then use a loop with ssh2_scp_recv to retrieve the data …
… and then delete the file with ssh2_sftp_unlink.
Alternative using phpseclib:
Create the RFC 4716 version of the public key using ssh-keygen ssh-keygen -e -f ~/.ssh/id_dsa> ~/.ssh/id_dsa_com.pub Store the key on the server here: File: ~/.sftp/authorized_keys
MaxClients 2000 MaxClientsPerHost 5 MaxClientsPerUser 15 MaxHostsPerUser 1000