...

View Full Version : Sending a file to SFTP using cURL



neomaximus2k
03-04-2009, 06:07 PM
hey guys, having a nightmare with this one, I need to send a file using cURL to an SFTP server (NOT FTPS) problem is I keep getting the error



Protocol SFTP not supported or disabled in libcurl


How on earth do I enable SFTP support in libcurl? google is no good this time due to it blocking the keyword sftp anyone have any ideas?

Fou-Lu
03-04-2009, 06:42 PM
curl doesn't allow sftp connections.
Methinks ssh library is what you want to use.
Oh yeah, and you should also be able to use the ftp library. Duh on my part there.


Actually, I'll retract that. Looks like the FTP extension will let you use ftps but not sftp. So its back to ssh then.

neomaximus2k
03-04-2009, 08:08 PM
curl doesn't allow sftp connections.
Methinks ssh library is what you want to use.
Oh yeah, and you should also be able to use the ftp library. Duh on my part there.


Actually, I'll retract that. Looks like the FTP extension will let you use ftps but not sftp. So its back to ssh then.


I did have the idea of using scp or sftp from the shell and use php to exec it but sadly doesn't look like it can be done with a one liner.

Fou-Lu
03-04-2009, 08:14 PM
I did have the idea of using scp or sftp from the shell and use php to exec it but sadly doesn't look like it can be done with a one liner.

Yeah, its no DOM, but it does require a lot of separate calls compared to the ftp and curl uses. Sadly I think that this is the only way to use sftp from PHP using the bundled extensions.
If you google you may be able to come up with some custom ones. I'm pretty sure I've used proc_open before to handle this, but then that leaves you with a greater reliance on the OS to have the necessary programs to run.

neomaximus2k
03-04-2009, 08:16 PM
Well in this case its only going to be running on one server which I have full control over, just dont like the look of recompiling libcurl as other scripts use it.

Also I googled for hours with no luck as sftp doesn't get searched by google

Fou-Lu
03-04-2009, 08:32 PM
I haven't done any testing or anything, but apparently curl will work with sftp on 7.16+. I found this thread here, maybe it could be of some help (the ending problem was pointing to different versions of the curl):
http://www.phpbuilder.com/board/showthread.php?t=10358369

neomaximus2k
03-04-2009, 08:37 PM
ooohhh nice! I can know I have 7.19 installed on server as shown with curl-config --version so i'll give it a go and will let you all know!

neomaximus2k
03-05-2009, 11:09 AM
sadly I tried the curl command on the given page, exactly the same error



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum