NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP and SFTP

Michael B Allen mba2000 at ioplex.com
Thu Apr 19 17:36:27 EDT 2007


On Thu, 19 Apr 2007 15:40:25 -0400
Brian Dailey <support at dailytechnology.net> wrote:

> Have any of you guys had any experience doing sftp transfers with PHP? I 
> need something fairly robust that allows me to confirm that the file did 
> indeed arrive intact.
> 
> I've looked into libssh2 (using ssh2.sftp:// wrapper) but I've had 
> little luck with that. The next best thing I've found is being able to 
> use a key to use ssh without entering a password (something I've done 
> before, but not with PHP).

I don't know anything about the libssh2 extension but you could simply
use popen to call scp. To validate the file was transferred successfully
you could then follow up with a call to popen and a command like:

 ssh host.foo.net "ls -l file.txt"

and then parse the size from the output and compare it to the local
file size.

Mike

-- 
Michael B Allen
PHP Active Directory Kerberos SSO
http://www.ioplex.com/



More information about the talk mailing list