Skip to main content

         This documentation site is for previous versions. Visit our new documentation site for current releases.      

This content has been archived and is no longer being updated.

Links may not function; however, this content may be relevant to outdated versions of the product.

Configuring custom SFTP and FTPS implementations for Pega applications

Updated on September 1, 2021

The Pega 7 Platform supports FTP Secure (FTPS) for Pega 7.1.8 or later and supports SSH FTP (SFTP) for Pega 7.1.9 or later. The FTP Server data instance provides built-in support for transferring files from the Pega server file system to an SFTP server. You can create custom SSH FTP (SFTP) and FTP Secure (FTPS) implementations for applications when you need additional capabilities or if you are using earlier versions of the Pega 7 Platform or PRPC.

For information about built-in functionality, see About FTP Server data instances.

Implementing custom SSH FTP (SFTP)

SourceForge open source software provides a custom implementation of SFTP that uses the underlying implementation in the Java Secure Channel file, JSCH.jar. Download and install this file for Pega 7 Platform versions prior to 7.2.2 if it is not already installed on your system.

  1. Download the latest JSCH.jar file from either of these sites:
    • SourceForge
    • JCraft
  2. Place the JSCH.jar file in the application server directory where JAR files are stored for selection during class loading.
    For example, on a Tomcat server the directory is C:\apache-tomcat-7.0.22\lib.
  3. Optional: Review the Parameters tab of the Activity form to see how parameters pass values in the Java code:
    Parameters tab on the Activity form
  4. Create an activity with a Java step that specifies the following code:

    // Declare parameters
    String HostName= tools.getParamValue("HostName");
    String UserName = tools.getParamValue("UserName");
    String Password = tools.getParamValue("Password");
    String remotePath =tools.getParamValue("remotePath");
    String localFile = tools.getParamValue("LocalFileName");
    String fileName = (new;

    //Trim values
    HostName=HostName.trim();UserName =UserName.trim();
    Password =Password.trim();remotePath =remotePath.trim();
    localFile =localFile.trim(); inputStream = null;
    com.jcraft.jsch.JSch jsch = null;
    com.jcraft.jsch.ChannelSftp sftpChannel=null;
    com.jcraft.jsch.Session ftpSession=null;
    try {
    jsch = new com.jcraft.jsch.JSch();
    oLog.debug("Getting jsch Session starts");
    ftpSession = jsch.getSession(UserName,HostName,22);

    java.util.Properties config = new java.util.Properties();
    config.put("StrictHostKeyChecking", "no");

    oLog.debug("Getting jsch Session ends");
    try {
    sftpChannel = (com.jcraft.jsch.ChannelSftp) ftpSession.openChannel("sftp");
    sftpChannel.connect();; fileF=new;
    * try {inputStream = new;
    catch ( exp)

    catch (com.jcraft.jsch.SftpException e)

    catch (com.jcraft.jsch.JSchException e) {

    oLog.debug(" End SFTWorker ->getfileContent()");
    if (sftpChannel != null && sftpChannel.isConnected()) {
    if (ftpSession != null && ftpSession.isConnected()) {

  5. Refer to the Java Secure Channel code example that is on the JCraft website.

Implementing custom FTP Secure (FTPS)

Use the custom implementation of FTPS that is provided by Apache Commons.

  1. Download the latest Apache Commons JAR file from the Apache Commons website.
  2. Find the FTPSClient Javadoc on the Apache Commons website.
  3. Manually specify the values of the highlighted lines of the following code to suit the requirements of your environment.

    boolean error = false;

    /** localFile variable holds reference to file on the PRPC server
    String localFile = "F:\\TestFile.txt";
    String localFile = ""; ftps = new"SSL", true);
    try {
    int reply;
    /** Enter the fully qualified name and port of the FTPS server
    ftps.connect("wpuripw7", 990);
    ftps.connect("", 990);
    /** Enter the user credentials to access FTPS server
    ftps.login("admin", "admin");
    ftps.login("", "");
    reply = ftps.getReplyCode();
    if (! {
    ftps.disconnect();"FTP server refused connection.");
    throw new PRRuntimeException("Could not connect to the FTP server");
    } catch ( e) {
    if (ftps.isConnected()) {
    try {"ERROR. Disconnecting from the FTP server.");
    } catch ( f) {
    // do nothing
    throw new PRRuntimeException("Error establishing connection with FTP server.", e);
    try {
    ftps.setFileType(; // can be BINARY or ASCII
    ftps.enterLocalPassiveMode(); input = new;
    /** Name the file as you want it on the FTPS server, usually its the same as source
    ftps.storeFile("TestFile.txt", input);
    ftps.storeFile("", input);
    } catch ( e) {
    error = true;
    oLog.error("Server closed connection.");
    throw new PRRuntimeException("Server closed connection", e);
    } catch ( e) {
    error = true;
    oLog.error("Error sending file: " + e.getMessage());
    throw new PRRuntimeException("Error sending file.", e);
    } finally {"Logging out of the session.");
    if (ftps.isConnected()) {
    try {"Disconnecting from the FTP server.");
    } catch ( f) {
    // do nothing

  4. Follow the comments in the code about the values that you need to specify:

    Line 9: String localFile, specify the file path on the PRPC server that needs to be sent over FTPS.
    Line 18: ftps.connect("", 990), specify the FTPS server and port.
    Line 23: ftps.login("", ""), specify the FTPS server credentials.
    Line 49: ftps.storeFile("", input), specify the name of the file that you want to be on the FTPS server.

  5. Include the edited code in the Java step of your activity.
  6. Install the latest Apache commons-net-3.3.jar file in the pr_engineclasses table by using the Import wizard, which provides access to the FTPSClient code.
  7. If you get a compilation error while saving the activity, do the following steps:

    1. In the System Management Application (SMA) ETier Runtime, look up the
      FTPSClient Class Name and Location

    2. Open the Dynamic System Setting (DSS) compiler/defaultPaths and add the output location that you specified in Step 7a, for example:

    3. In the System Management Application (SMA), click Advanced > Class Management > Refresh External JARs.


Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best. is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us