Writing Job Results to a SFTP Server

This article explains how to send job results directly to your sftp server.

Table of Contents


  • Basic knowledge of Treasure Data, including the toolbelt.
  • An sftp server

Basic Usage

Our Premium plan includes advanced security features, which includes a list of static IPs Treasure Data is using. You can limit the access to your endpoint by using these IPs. Please contact support@treasuredata.com if you need it too.

Get your credential for your SFTP server

First, please obtain your credential to access your SFTP server.

Write the query

Please visit the Treasure Data Console query editor page and compile your query.

Specify the Result Export target

In the same window, click the Add button in the Result Export section and select SFTP from the drop down menu. Please fill out all the information, including your Host, Port, Username, Private Keyfile, and Passphrase of keyfile (if available).

Execute the query

Finally, either save the query with a name and run or just run the query. Upon successful completion of the query, its result will be automatically imported to the specified Container destination:

Usage from CLI

You can also use CLI for Result Export to SFTP.

secret_key_file case

Please note that escape newline with backslash in key.


$ td query --result '{"type":"sftp","host":"xx.xx.xx.xx","port":22,"username":"xxxx","secret_key_file":"{\"content\":\"-----BEGIN RSA PRIVATE KEY-----\nABCDEFJ\nABCDEFJ\n-----END RSA PRIVATE KEY-----\"}","secret_key_passphrase":"xxxxxx", "user_directory_is_root":true,"path_prefix":"/path/to/file","file_ext":".csv","sequence_format":"","header_line":true,"quote_policy":"MINIMAL","delimiter":",","null_string":"","newline":"CRLF"}' -d sample_datasets "select * from www_access" -T presto

user/password case


$ td query --result '{"type":"sftp","host":"xx.xx.xx.xx","port":22,"auth_method":"Password","username":"xxxx","password":"xxxxx","user_directory_is_root":true,"path_prefix":"/path/to/file","file_ext":".csv","sequence_format":"","header_line":true,"quote_policy":"MINIMAL","delimiter":",","null_string":"","newline":"CRLF"}' -d sample_datasets "select * from www_access" -T presto

Last modified: Jul 06 2016 05:08:37 UTC

If this article is incorrect or outdated, or omits critical information, please let us know. For all other issues, please see our support channels.