SFTP Filesystem

Use ObjectStoragePath with SFTP/SSH servers via the sshfs library.

pip install apache-airflow-providers-sftp[sshfs]

URL format: sftp://connection_id@hostname/path/to/file (also supports ssh://).

Configuration

Uses the standard SFTP connection. The following extras are supported:

  • key_file - path to private key file

  • private_key - private key content (PEM format)

  • private_key_passphrase - passphrase for encrypted keys

  • no_host_key_check - set to true to skip host key verification

See SFTP Connection for details.

Example

from airflow.sdk import ObjectStoragePath

path = ObjectStoragePath("sftp://my_conn@myserver/data/file.csv")

# read
with path.open() as f:
    data = f.read()

# write
with path.open("w") as f:
    f.write("content")

# list
for p in path.parent.iterdir():
    print(p.name)

# copy
path.copy(ObjectStoragePath("file:///tmp/local.csv"))

Was this entry helpful?