0

I'm interested in trying to get SFTP working with the following PHP method: ftp_ssl_connect(host,port,timeout);

I notice that on W3CSchools (http://www.w3schools.com/php/func_ftp_ssl_connect.asp) there is the following note:

Note: This function is only available if both the ftp module and the OpenSSL support is built statically into PHP.

I am left with the question as to how to "build statically" both the "ftp module" and "OpenSSL support" into PHP. I have googled around and there seems to be very sparse information on this subject.

When I currently try to run the code from W3CSchools with legitimate credentials, I constantly get "false" returned. I can successfully SFTP in with the same credentials and port I am using with PHP, so that isn't the problem.

I realize there is another similar question on StackOverflow; however, that question does not even mention nor give an explanation as to how to use the PHP function ftp_ssl_connect() and I would still like to know how to use it and when to use it.

Community
  • 1
  • 1
Bryan Miller
  • 3,262
  • 4
  • 27
  • 51
  • I had already seen that question; however, I was looking for an explanation as to how to use ftp_ssl_connect(), which that other question does not address. – Bryan Miller Feb 25 '16 at 16:15
  • The `ftp_ssl_connect` has nothing to do with the SFTP. I wanted to show you how you actually implement SFTP in PHP. – Martin Prikryl Feb 25 '16 at 20:37
  • How can one use ftp_ssl_connect with PHP? Does one have to compile their own binaries on ubuntu? – Bryan Miller Feb 26 '16 at 00:49
  • That's a completely different question that what you asked originally. Your question is about SFTP. Again the `ftp_ssl_connect` has **nothing** to do with SFTP. If you want to know how to use `ftp_ssl_connect`, ask a new question. This is Q&A site, not a discussion forum. – Martin Prikryl Feb 26 '16 at 06:26

1 Answers1

3

SFTP (not to be confused with FTPS) is a tool provided by the OpenSSH suite (and other implementations) to securely transfer files over an SSH connection. It is in no way related to FTP or FTPS, which is what the function you're using is for.

You are probably looking for https://secure.php.net/manual/en/function.ssh2-sftp.php and the other related functions.

  • Why would one want the OpenSSH suite option in comparison to SSH FTP, which I think you are calling FTPS? – Bryan Miller Feb 25 '16 at 16:14
  • @user3089840 SSH FTP is not FTPS. FTPS is FTP over TLS/SSL. The FTP over SSH is hardly ever used. See http://stackoverflow.com/q/440463/850848 – Martin Prikryl Feb 25 '16 at 20:39