Skip to content

SFTP

SFTP servers: the sftp destination, from the sftp package. Declare the package once in dependencies.yml; DRE installs it on demand:

dependencies.yml
plugins:
- sftp

Set in profiles.yml, under destinations:, in a target with type: sftp.

Field Default Notes
host (required) SFTP server.
port 22 Port.
username (required) User name.
accept_unknown_host Trust a host missing from known_hosts.
password Password (or set private_key_path) Secret: use env_var().
private_key_path Private key file (instead of a password) A file path; ~/ is your home directory.
private_key_passphrase The private key’s passphrase. Secret: use env_var().
known_hosts_path Known_hosts file (default ~/.ssh/known_hosts) A file path; ~/ is your home directory.
private_key The private key’s text, e.g. from env_var() (instead of private_key_path) Secret: use env_var().
host_key_fingerprint Pinned host key, SHA256:… (otherwise ~/.ssh/known_hosts is used)
use_agent Sign in with the keys in your SSH agent (SSH_AUTH_SOCK), instead of a password or key file.
allow_rsa_keys Deprecated, no effect: RSA private keys need no opt-in any more.
connect_timeout 30s How long to wait for a connection (30s, 2m, or seconds) A duration (30s, 2m) or seconds.
timeout 60s How long a read or write may make no progress before it fails. A duration (30s, 2m) or seconds.
retries 3 How many times to try again after a temporary error (0: never)
retry_wait The first wait before trying again (30s), doubling each try; a server’s Retry-After wins. A duration (30s, 2m) or seconds.
max_retry_wait 10m The longest wait between tries (10m) A duration (30s, 2m) or seconds.

Set in the report’s output.destination entry.

Option Type Default Notes
if_exists string overwrite When a file is already at the path: overwrite it, fail with error, or number the new one. One of overwrite, error, number.
atomic boolean true Upload under a temporary name, then rename, so no half-written file appears.
temp_dir string Where the temporary file goes (on the same server), for receivers that pick up any new file.
retries integer How many times to try again after a temporary error such as a rate limit (0: never)
retry_wait string The first wait before trying again (30s), doubling each try; a server’s Retry-After wins.
max_retry_wait string The longest wait between tries (10m)

host, port (22), username, and password, private_key_path or private_key (+ private_key_passphrase). private_key is the key’s text, for when it can’t be a file (a CI secret: private_key: "{{ env_var('SFTP_KEY') }}"); a key stored on one line with literal \n gets its line breaks back. Set private_key_path or private_key, not both. The host key is checked against known_hosts_path (default ~/.ssh/known_hosts) or a pinned host_key_fingerprint (SHA256:...). In private_key_path and known_hosts_path, a leading ~/ is your home directory. Unknown hosts are refused unless accept_unknown_host is true. With use_agent set to true, it signs in with the keys in your SSH agent (SSH_AUTH_SOCK; the OpenSSH agent’s pipe on Windows) instead of a password or key file, so the key never enters DRE. Missing directories are created. Uploads go under a temporary name first (atomic, temp_dir: see Uploads under a temporary name); if_exists is checked in the same step as the write (see A file already at the path). The postgres source’s ssh: block takes the same settings.

RSA private keys work like any other key. Until rsa 0.10.0 fixed RUSTSEC-2023-0071, DRE warned about them, and allow_rsa_keys silenced or refused them. That option is now deprecated and has no effect (sftp 1.4.0, postgres 1.7.0, clickhouse 1.1.0): a set value warns once per run, and it stops being accepted in the next minor release. Remove it from your profiles.

Deliver a file without exposing a partial upload

Section titled “Deliver a file without exposing a partial upload”

Use the complete SFTP delivery example for a runnable local server and report. For a real receiving server, use its verified host key and a key file:

profiles.yml
destinations:
partner:
targets:
dev: {deliver: false}
prod:
type: sftp
host: sftp.example.com
username: reporting
private_key_path: ~/.ssh/id_ed25519
known_hosts_path: ~/.ssh/known_hosts
# within a report's output
destination:
profile: partner
path: "incoming/report-{{ run.date.yyyymmdd }}.csv"
atomic: true
temp_dir: staging
if_exists: error

temp_dir and the final path must allow a rename on the same server. The receiving system should watch incoming, not staging. sftp/host-key-mismatch requires verifying the server identity with its administrator before updating the pin; disabling the check hides a changed server. sftp/file-exists needs a new dated name or a deliberate replacement policy. See atomic upload behavior, destination keys and destination.