问题
I wrote a PHP program that performs a rawlist function on a remote server with many (about 1000) directories. The phpseclib SFTP rawlist method works, but it takes over 12 minutes to traverse the directory tree on the server. On the other hand, the plain old FTP rawlist function (ftp_rawlist) returns the same results in about 30 seconds.
I understand that an SSH connection adds overhead because of encryption, but this seems excessive. I've had the same SFTP results from PHP 5.3 and 5.4 systems running on Windows Server 2012 and Windows 7, resp. Both installation have mcrypt and gmp enabled.
Here is a basic version of the program I've been testing with:
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . 'C:/path-to/phpseclib');
include 'Crypt/RSA.php';
include 'Net/SFTP.php';
$rsa = new Crypt_RSA();
$priKey = file_get_contents('C:/path-to/my_private_key.ppk');
$rsa->loadKey($priKey);
$sftp = new Net_SFTP('my_ssh_server_URI', 22);
if (!$sftp->login('my_user_id', $rsa)) {
exit("Login Failed\n");
}
print_r($sftp->rawlist('starting_directory', true));
?>
I just wonder if someone has run into the same issue with the SFTP "_list" method and come up with a work-around to improve performance. Thank you.
来源:https://stackoverflow.com/questions/28502422/slow-response-to-a-recursive-rawlist-request-in-phpseclib