Forum Moderators: coopster

Message Too Old, No Replies

SFTP with PHP

is ftp_ssl_connect up to the job?

         

PHP_Chimp

8:21 pm on Oct 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does anyone know a method of implementing SFTP through PHP?

I have done a general search on the web and there seem to be lots of opinions...most of which vary wildly. So does anyone have any experience of trying to get the ftp_ssl_connect to work as an SFTP set up?

I understand that the data is not encrypted with FTP however in this case the data is a load of maths for a chemistry PHD, so not sensitive financial information ;) So encryption that can only be broken by government organisations is not really required.

eelixduppy

7:25 am on Oct 9, 2007 (gmt 0)



Have you read the documentation for the function? [php.net...]

There are examples there and also requirements for this to work. Make sure OpenSSL is enabled on your server.

PHP_Chimp

8:03 am on Oct 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, iv read it and have tried to test it as well. It is establishing a connection, but the connection is constantly being actively rejected by the host.
I have an SFTP program that connects and transmits, so I know that I have the correct info for the host server.

The first user comment for the function remarks that SSL-FTP!= SFTP.
I am trying to decide if this project is worth bothering with, or if there is a different way to go about it. As it seems that SFTP is outside of what php is capable of without some significant effort.

So the point was in the title...is ftp_ssl_connect actually able to be used as an SFTP connect? It seems that the answer is no.

coopster

4:28 pm on Oct 9, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Does anyone know a method of implementing SFTP through PHP?

I prefer using the ftps://wrapper [php.net] with the filesystem functions. You can set context options for the underlying transports [php.net].

That is the simplest way to get the job done. If that doesn't work, use fsockopen [php.net] to roll your own. If you are attempting this on a Windows box you will have to read the notes, there is always a hitch with that particular server.

PHP_Chimp

4:33 pm on Oct 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for that, much better idea to use the file functions and not bother with the ftp functions.
Thanks again.

coopster

4:46 pm on Oct 9, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You're welcome. Let us know how it goes for you, it can be a little intimidating at first, but stick with it.