Reputation: 62404
I've looked into the SSH2 module for PHP, but it would require a PHP recompile on a server which is very bloated. It's far more of a risk than we'd like to take on right now.
Is it possible for me to use cURL to grab a few files over SSH? I've done some Googling and found a few sources but nothing 100% clear on whether this is possible.
Upvotes: 2
Views: 2688
Reputation: 9671
CURL won't work unfortunately. You can, as @Michael suggested, use scp, or if you need to copy the files on a regular basis, I would suggest rsync
as it will only transfer the differences between the file content.
exec('/usr/bin/rsync -az user@remotehost:/path/to/directory/* /path/to/local/directory/');
Flag-a
will use archive mode, see the documentation for more details. The -z
flag will compress the transfer.
rsync
will also transfer via SSH
, so make sure you have the privat/public keys set up correctly.
Upvotes: 1
Reputation: 270637
I'm not certain about cURL, but if you don't want to recompile but the server has ssh clients installed already, you can make a system call to scp
. It will work best, of course, if you have SSH keys in place between the local and remote hosts.
shell_exec("/usr/bin/scp -i private_key_identity user@host:/path/to/remote/file /local/path");
Upvotes: 2