SFTP Setup Guide link
Updated 14 days ago
Follow our setup guide to sync files from your SSH server to your destination using SFTP.
To set up the Fivetran SFTP connector, you need the following:
- An account on an SSH server containing files with supported filetypes and encodings
- The ability to log in to this account using either a password or key pair
Begin Fivetran configurationlink
In the connector setup form, enter the Destination schema and Destination table name of your choice.
Select your Connection Method. You can Connect directly or Connect via SSH Tunnel:
Connect directly: Fivetran will connect directly to your SFTP Server. This is the simplest method. To connect directly, Fivetran's IP addresses should be safelisted in your firewall.
Connect via SSH Tunnel: Fivetran will connect to a separate server in your network which provides an SSH tunnel to your SFTP Server. You must choose this option if your SFTP Server is in an inaccessible subnet.
If you use a keypair for logging into your SFTP server, set the Login with keypair? toggle to ON.
If Login with keypair? toggle is ON or Connection Method is Connect via SSH Tunnel, make a note of the automatically generated public key and proceed to the next section.
If you use password for logging into your SFTP server and chose Connection Method as Connect directly, proceed to the final section.
Configure your keypair in a text editorlink
If you want to connect via SSH Tunnel, this step is mandatory as we only support keypair based login to Tunnel Host. If you want to connect directly to your SFTP server, then this step is only required if your SSH user account uses key pairs to log in.
You need to create a group and SSH user, add the SSH user to the group, create the
.ssh directory and
authorized_keys file, and grant them permissions, unless they already exist and have the permissions granted. To do it, log in to your server and run the following commands:
sudo groupadd fivetran
Create an SSH user
sudo useradd -m -g fivetran fivetran
Switch to your
sudo su - fivetran
chmod 700 ~/.ssh
Switch to the
chmod 600 authorized_keys
Using your favorite text editor, add the public ssh key from the Fivetran setup form to the authorized_keys file. The key must be all on one line. Make sure no line breaks are introduced when cutting and pasting.
Add the Fivetran public key to the /.ssh/Authorized_keys file on any SSH account you wish to use.
IMPORTANT: If you choose both login with keypair and connect via SSH Tunnel, you need to configure same keypair in both the servers.
Finish Fivetran configuration link
In the connector setup form, enter the following details:
- Password (not required for keypair login)
- Host Address
If you selected Connect via an SSH tunnel as Connection Method, provide the following information:
- Tunnel Username
- Tunnel Host Address
- Tunnel Port
IMPORTANT: If you entered DNS instead of IP Address in Host Address of SFTP Server, you must have ip address to DNS mapping for SFTP Server in /etc/hosts file of tunnel Host Or the name should resolve to ip using Internal DNS server.
Choose your configuration options. Using these configuration options, you can select subsets of your folders, specific types of files, and more to sync only the files you need in your destination. In addition, setting up multiple connectors targeted at the same file system but with different options allows you to slice and dice a file system any way you'd like.
You can use the following configuration options:
Beta Primary Key used for file process and load - Use this option to let Fivetran know how you'd like to update the files in your destination. When you modify a previously synced file, it determines if we should replace the rows in the destination table or append the new rows to the table:
- If you select Upsert file using file name and line number, we will upsert your data using surrogate primary keys _file and _line. You'll have files with unique names containing net-new data.
- If you select Append file using file modified time, we will upsert your files using surrogate primary keys _file and _line and _modified. You can track the full history of a file or set of files and your files contain a mix of old and new data or data that is updated periodically.
- If you select Upsert file using custom primary key, you can keep the most recent version of every record and your files contain a mix of old and new data, or are updated periodically. You can choose which primary key to use after you save and test. For more information, see our documentation.
NOTE: To ensure data integrity, we recommend that you don't change the primary keys once the initial sync is completed.
(Optional) Folder Path - Use the folder path to specify a portion of the file system in which you'd like Fivetran to look for files. We examine files under the specified folder and all of its nested subfolders for files we can sync. If you don't provide a prefix, we'll look through the entire file system for files to sync.
(Optional) File Pattern - Use a regular expression as the file pattern to decide whether or not to sync specific files. The pattern applies to everything under the prefix (folder path). If you're unsure what regular expression to use, you can leave this field blank, and we'll sync everything under the prefix.
For example, if under the prefix
logs, you have three folders:
errors. Using the pattern
\d\d\d\d/.*, you can exclude all the files in the
\d\d\d\donly applies to the folders whose name consists of four consecutive digits, and
/applies to any files in these folders
File Type - Use the file type to choose the parsing strategy for files without file extensions. If you save your files with improper extensions, you can force them to be synced as the selected file type.
If you select infer, we infer the type from a file's extension (.csv, .tsv, .json, .avro, or .log).
NOTE: If you have XML files, don't select infer. We sync XML files only when you select the file type as xml. For more information about the file size, see our documentation.
NOTE: If you have PGP encrypted files, do not select infer.
If you choose a file type, we interpret every file we examine as the file type you select, so make sure everything we sync has the same file type.
For example, if you have an automated CSV output system that saves files without a .csv extension, you can specify the type as csv, and we will sync them correctly as CSVs.
If you select xml, we load your XML data into the
_datacolumn without flattening it.
(Optional) JSON Delivery Mode - Available when JSON or JSONL is selected in File Type. Use this option to choose how Fivetran should handle your JSON data.
- If you select Packed, we load all your JSON data into the
_datacolumn without flattening it.
- If you select Unpacked, we flatten one level of columns and infer their data types.
- If you select Packed, we load all your JSON data into the
Compression - Use the compression option to choose the compression strategy to decompress files without compression extensions. If your files are compressed but do not have extensions indicating the compression method, you can decompress them according to the selected compression algorithm.
If all of your compressed files are correctly marked with a matching compression extension (.bz2, .gz, .gzip, .tar, or .zip), you can select infer.
If you select uncompressed, we do not decompress the files and sync the uncompressed files.
If you choose a compression format, we decompress every file using the format you select.
For example, if you have an automated CSV output system that GZIPs files to save space but saves them without a .gzip extension, you can set this field to GZIP. We will decompress every file that we examine using GZIP.
Error Handling - Use the error handling option to choose how to handle errors in your files. If you know that your files contain some errors, you can choose to skip poorly formatted lines.
If you select skip, we ignore improperly formatted data within a file, allowing you to sync only valid data.
If you select fail, we do not sync a file if we detect improperly formatted data in the file.
TIP: We recommend that you select fail unless you are sure that you have undesirable, malformed data.
You will receive a notification on your Fivetran dashboard if we encounter errors.
(Optional) To use the advanced configuration options, set the Enable Advanced Options toggle to ON.
You can use the following configuration options for specific use cases:
(Optional) Archive Folder Pattern - Use a regular expression to filter and sync files from archived folders. We sync the files in compressed archives with filenames matching the specified pattern. If there are multiple files within archive (TAR or ZIP) folders, you can use the archive folder pattern to filter file types.
For example, if you specify the archive folder pattern as
.*json, we will sync only the files that end in a .json file extension from the archive folder.
NOTE: This is only used to filter out the files inside the archived folder. All the file matching the File Pattern will be listed
(Optional) Null Sequence - Specify the value indicating null if your CSVs use a special value indicating null.
Only use this field if you are sure your CSVs have a null sequence. CSVs have no native notion of a null character. However, some CSV generators have created one, using characters such as
\Nto represent null.
TIP: The text is un-escaped before the null sequence is matched, so don't use the escape character in your null sequence.
(Optional) Delimiter - Specify the delimiter. The delimiter is a character used in files to separate one field from the next. Fivetran tries to infer the delimiter, but in some cases, this is impossible. If your files sync with the wrong number of columns or uses a unique delimiter, consider setting this value. For example, if you have tab-delimited files, you must enter
\t, and if you have pipe-delimited files, enter
If you leave this field blank, we infer the delimiter for each file. You can store files of many different types of delimiters in the same folder with no problems. For more information on the delimiter inference, see our documentation.
If you specify a delimiter, we parse all the CSV, TSV, and TXT files in your folder path with this delimiter.
NOTE: You can also specify a multi-character delimiter in this field. A custom multi-character delimiter (excluding "\t" and "\s") should be mentioned only if the source contains only csv files, else it might lead to data integrity issues for other files. The length of custom multi-character delimiter should not exceed 15 characters.
(Optional) Escape Character - Set the escape character if your CSV generator follows non-standard rules for escaping quotation marks.
Only use this field if you are sure your CSVs have a different escape character. CSVs have a special rule for escaping quotation marks compared to other characters; they require two consecutive double quotes to represent an escaped double quote. However, some CSV generators do not follow this rule and use different characters like backslash for escaping.
(Optional) Skip Header Lines - Use this option to skip over fixed-length headers at the beginning of your CSV files. Set the toggle to ON, and then in the Number of skipped header lines field, specify the number of header lines you want to skip.
Some CSV-generating programs include additional header lines or empty lines at the top of the file. The header consists of a few lines that do not match the format of the rest of the rows in the file. These header rows can cause undesired behavior because we attempt to parse them as if they were records in your CSV.
(Optional) Skip footer Lines - Use this option to skip over fixed-length footers at the end of your CSV files. Set the toggle to ON, and then in the Number of skipped footer lines field, specify the number of footer lines you want to skip.
Some CSV-generating programs include a footer at the bottom of the file. The footer consists of a few lines that do not match the format of the rest of the rows in the file. These footer rows can cause undesired behavior because we attempt to parse them as if they were records in your CSV.
(Optional) Headerless Files - Set the toggle to ON if your CSV-generating software doesn't provide a header line for the documents. Fivetran can generate the generic column names and sync data rows with them.
Some CSV-generating programs do not include column name headers for the files; they only contain data rows. When you set the toggle to ON, we generate generic column names following the convention of
column_nto map the rows.
(Optional) Line Separator - Specify the custom line separator for your CSV files. The line separator is used in files to separate one row from the next.
If you leave this field blank, we use the new line character
\nas the line separator by default.
If you specify a line separator, we parse all the CSV files in your folder path with this line separator.
(Optional) PGP Encryption Options - Use this option to sync PGP encrypted files. Set the toggle to ON and specify the following:
- PGP Private Key - Upload the PGP secret key as an attachment.
- Passphrase - Enter the passphrase you used to generate the key.
- (Optional) Signer's Public Key - Upload the signer's public key as an attachment. This key is used for verifying the files.
NOTE: For PGP decryption processes, we strictly comply with the RFC4880 standard. We support syncing only base64 encoded files.
Click Save & Test. Fivetran will take it from here.
Confirm that the server SSH key is trusted when the initial tests are run.