2 Replies Latest reply on Jul 22, 2010 2:26 PM by dalrympj

    How can you FTP with SSH using CF 7?

    retrocane
      We're migrating content to new servers that require SSH connection for FTP.

      Currently the CF code uses CFFTP tag to transfer files from the test to production servers; but what will I need to do to have the CF code transfer files over SSH?

      The servers are using CF version 7 and run on IIS.

      Thank you,
      Josh
        • 1. Re: How can you FTP with SSH using CF 7?
          Neo Rye Level 1
          You don't! Maybe in CF8, but not with cf7.

          I used a custom tag called cfx_SecureFTP and cfx_SecureFTP. Can't find them anymore on Google, but I could email you what I have.

          OR maybe this would work for you:
          http://www.jscape.com/sftp/index.html
          " did this just recently for a client. We implemented a fairly simple
          solution using Jscape Secure FTP Factory for Java. It works well, however I
          was not able to get listeners to work, so reporting on successfully
          transfers is not great. I do a directory listing after the upload and look
          for the file I just uploaded. This works in my case, because the file name
          is always unique. Might not work for you. Maybe you can find a better way.
          The url is http://www.jscape.com/sftp/index.html it costs $499.00.

          This is the code we used to implement it:

          <cfset jarpath = 'C:\CFusionMX7\wwwroot\WEB-INF\lib\sftp.jar'>


          <cfscript>

          system = CreateObject("java", "java.lang.System");
          classpath = system.getProperty("java.class.path");
          if (FindNoCase("sftp", classpath) LTE 0)
          {
          classpath = classpath & ";#jarpath#";
          system.setProperty("java.class.path",classpath);
          }


          util = CreateObject("java", "com.jscape.inet.ssh.util.SshParameters");
          sLogin =
          util.init('#dailyftp_profiles.ftpaddress#','#dailyftp_profiles.username#','#dailyftp_prof iles.
          password#');
          sftpObject = CreateObject("java", "com.jscape.inet.sftp.Sftp");
          sftp = sftpObject.init(sLogin);

          // connect and set timeout
          sftp.connect();
          sftp.setTimeout(1000);

          // set remote directory if requested
          if (#dailyftp_profiles.homedirectory# neq ''){
          sftp.setDir("#dailyftp_profiles.homedirectory#");
          }

          sftp.setAuto(true);
          // upload the file
          sftp.upload("#request.general_tempfile_root##tempfilename#");
          sftp.renameFile("#tempfilename#","#remoteFileName#");
          //get listing
          dirListing2 = sftp.getDirListingAsString();
          // disconnect from SSH server
          sftp.disconnect();
          </cfscript>

          <!--- check that the file was uploaded --->
          <cfif not dirListing2 contains '#remoteFileName#'>
          <!--- do error handling here for failed upload --->
          </cfif>

          from link:
          http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:234022
          • 2. Re: How can you FTP with SSH using CF 7?
            dalrympj

            Neo Rye -

             

            I was also using a custom tag "cfx_SecureFTP" on ColdFusion MX7 for FTP uploading. I have no idea where it came from because it was set up by my predecessor.

             

            Now I've upgraded to ColdFusion 9 and that custom tag won't work any more. Any ideas on why that might be?

             

            Thanks!

            -Jessie