Description

The SFTPReceiver automatically sends files to another server via SFTP.


In This Article


Receiver Parameters

The following parameters should be defined for the SFTPReceiver. Items with an asterisk(*) are required.

  • payloadFilesPath* - Defines the base location of the files to send
  • payloadFilesSubDir - Defines the naming convention for subdirectories within the payloadFilesPath
  • payloadFilesDescriptor - Defines the name of the descriptor of files to be sent from payloadFilesSubDir
    • Example: 
      • txt - Sends only files whose extension is txt
      • xls - Sends only files whose extension is xls
  • propertiesFilePath* - Defines the location of the configuration properties file
  • propertiesSubDir - Defines the subdirectory within the propertiesFilePath where the properties file is located
  • propertiesFileName* - Defines the file name of the configuration properties file 
  • logFileCount* - Defines the number of requests that are executed before logging a message to the console
  • threadCount* - Defines the number of requests that may be sent simultaneously.



Configuration (Properties file)

The SFTPReceiver must read from a configuration file that contains information to be able to connect to the SFTP server. The configuration file must contain the properties listed below. Items with an asterisk(*) are required.

  • server* - The address of the SFTP server
  • username* - The username of SFTP client
  • password - The password of the SFTP client (Optional if SFTP server using the ssh key (Example: password=).
  • port - The port number where the SFTP server "listens" for client connections. If this is not set, the port will automatically be set to 22 (which is commonly used as the default port for SFTP protocol)
  • targetLocation* - The target location in the SFTP server where the files will be transferred. The target location must be ended with the file separator. Example: File Separator in the Linux "/" and in Windows "\\"
  • sshKnownHostsLocation -  Defines the path to a file having a list of known hosts. The ssh known_hosts file is a file that stores the public key of all of the servers that you have connected using ssh. 
  • privateKeyPath - There are 2 ways users can connect to the Server. One is by using a username and password. The other is using a private key. If the private key method will be used, then the user needs to provide the location of the private key file. (Example: privateKeyPath=)
  • passPhrase - This works with privateKeyPath. This is optional and is only needed when the user should also enter a passPhrase.
  • permission - This sets the permissions of the file transferred to the remote location. When the file is transferred but cannot be read and/or written to, the permission can be set with this parameter for the transferred file. (See example located below configuration example).



Configuration File Example

server=192.168.254.7
username=anonymous
password=anonymous
port=22
targetLocation=/Users/SFTPServer/Downloads/
sshKnownHostsLocation=/Users/SFTPClient/.ssh/known_hosts
privateKeyPath=/Users/SFTPClient/.ssh/id_rsa
passPhrase=anonymous
permission=700

Permission Parameter Example
The transferred file needs read, write, and execute permissions. The available numbers are:
  • 4 = read
  • 2 = write
  • 1 = execute

For all three permissions, the number would be '7' (4+2+1). 
There are three positions in the number, each represents a specific item: 
  • Position 1 = Reader
  • Position 2 = User
  • Position 3 = Group


For this example, the value will be '700' to give read, write, and execute permissions to the reader for the transferred file. The user and group will not have these permissions, as noted by the zeros.


Possible Errors

The following errors can occur when using the SFTPReceiver:

UnknownHostKeyException Error

When using the SFTPReceiver, one possible error that occurs is the UnknownHostKeyException. This occurs when Genrocket cannot connect to your SFTP server.


You can do the following commands below:

ssh-keyscan -t rsa <HOST_NAME> >> ~/.ssh/known_hosts
ssh-keyscan -t rsa <IP_ADDRESS_OF_HOST_NAME> >> ~/.ssh/known_hosts


Invalid Privatekey Error

Generic

SFTPReceiver does not support the OpenSSH key format for passwordless login. If the private key is in OpenSSH format, users will receive an error saying, “invalid privatekey”.  

A solution to this is converting the key using the following: 
ssh-keygen -p -f <yourpathwhereidRSAFileIs> -m pem


Example Test Runs

The following example test runs were performed on a machine with the following specifications:

  • MacMini
  • Mac OS Mojave
  • 16GB RAM
  •  Intel Core I5 CPU
  • 500GB SSD

Test data used in each test run met the following criteria:

  • All test files were generated by GenRocket
  • One thousand files were generated 
  • Each file is 3KB in size

For brevity, the example runs below show only the first 100 file transfers. 


Test Run With 1 Thread (4m:29s)

***** Transferred 0 of 1000 files to SFTP Server using 1 thread/s - Elapsed Time: 0s *****
..........
***** Transferred 10 of 1000 files to SFTP Server using 1 thread/s - Elapsed Time: 2s *****
..........
***** Transferred 20 of 1000 files to SFTP Server using 1 thread/s - Elapsed Time: 2s *****
..........
***** Transferred 30 of 1000 files to SFTP Server using 1 thread/s - Elapsed Time: 2s *****
..........
***** Transferred 40 of 1000 files to SFTP Server using 1 thread/s - Elapsed Time: 2s *****
..........
***** Transferred 50 of 1000 files to SFTP Server using 1 thread/s - Elapsed Time: 2s *****
..........
***** Transferred 60 of 1000 files to SFTP Server using 1 thread/s - Elapsed Time: 2s *****
..........
***** Transferred 70 of 1000 files to SFTP Server using 1 thread/s - Elapsed Time: 2s *****
..........
***** Transferred 80 of 1000 files to SFTP Server using 1 thread/s - Elapsed Time: 2s *****
..........
***** Transferred 90 of 1000 files to SFTP Server using 1 thread/s - Elapsed Time: 2s *****
..........
***** Transferred 100 of 1000 files to SFTP Server using 1 thread/s - Elapsed Time: 2s *****


Generic


Test Run With 2 Threads (2m:55s)

Generic
***** Transferred 0 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 0s *****
.....
***** Transferred 10 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 1s *****
.....
***** Transferred 20 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 1s *****
.....
***** Transferred 30 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 1s *****
.....
***** Transferred 40 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 1s *****
.....
***** Transferred 50 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 1s *****
.....
***** Transferred 60 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 1s *****
.....
***** Transferred 70 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 1s *****
.....
***** Transferred 80 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 1s *****
.....
***** Transferred 90 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 1s *****
.....
***** Transferred 100 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 1s *****



Test Run With 3 Threads (2m:24s)

Generic
***** Transferred 0 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 0s *****
...
***** Transferred 10 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 1s *****
...
***** Transferred 20 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 1s *****
....
***** Transferred 30 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 1s *****
...
***** Transferred 40 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 1s *****
...
***** Transferred 50 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 1s *****
...
***** Transferred 60 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 1s *****
...
***** Transferred 70 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 1s *****
...
***** Transferred 80 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 1s *****
...
***** Transferred 90 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 1s *****
....
***** Transferred 100 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 1s *****


Test Run With 5 Threads (2m:0s)

Generic
***** Transferred 0 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 0s *****
..
***** Transferred 10 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 1s *****
..
***** Transferred 20 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 1s *****
..
***** Transferred 30 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 1s *****
..
***** Transferred 40 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 1s *****
..
***** Transferred 50 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 1s *****
..
***** Transferred 60 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 1s *****
..
***** Transferred 70 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 1s *****
..
***** Transferred 80 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 1s *****
..
***** Transferred 90 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 1s *****
..
***** Transferred 100 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 1s *****



Test Run with 10 Threads (1m:44s)

***** Transferred 0 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 0s *****
.
***** Transferred 10 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 1s *****
.
***** Transferred 20 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 1s *****
.
***** Transferred 30 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 1s *****
.
***** Transferred 40 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 1s *****
.
***** Transferred 50 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 1s *****
.
***** Transferred 60 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 1s *****
.
***** Transferred 70 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 1s *****

***** Transferred 80 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 1s *****
.
***** Transferred 90 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 1s *****
.
***** Transferred 100 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 1s *****