> ## Documentation Index
> Fetch the complete documentation index at: https://docs.open-metadata.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Run the SFTP Connector Externally

> Use YAML to configure SFTP ingestion, enabling structured metadata extraction for secure file transfer protocol servers.

![SFTP](https://docs.open-metadata.org/public/images/connectors/sftp.webp)

# SFTP

BETA

In this section, we provide guides and references to use the SFTP connector.
Configure and schedule SFTP metadata workflows from the OpenMetadata UI:

* [Requirements](#requirements)
* [Metadata Ingestion](#metadata-ingestion)

## How to Run the Connector Externally

To run the Ingestion via the UI you'll need to use the OpenMetadata Ingestion Container, which comes shipped with
custom Airflow plugins to handle the workflow deployment.

If, instead, you want to manage your workflows externally on your preferred orchestrator, you can check
the following docs to run the Ingestion Framework **anywhere**.

> [card] [External Schedulers](https://docs.open-metadata.org/v2.1.x/deployment/ingestion.md)
>
> Get more information about running the Ingestion Framework Externally

## Requirements

### Python Requirements

Use Python 3.10 or later. Python 3.12 is recommended, because it is what the OpenMetadata 2.0 ingestion images use. To confirm the supported range for your release, check the `Requires-Python` metadata of that release’s `openmetadata-ingestion` package.

To run the SFTP ingestion, you will need to install:

```bash theme={null}
pip3 install "openmetadata-ingestion[sftp]"
```

## Metadata Ingestion

All connectors are defined as JSON Schemas.
[Here](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-spec/src/main/resources/json/schema/entity/services/connections/drive/sftpConnection.json)
you can find the structure to create a connection to an SFTP server.
In order to create and run a Metadata Ingestion workflow, we will follow
the steps to create a YAML configuration able to connect to the source,
process the Entities if needed, and reach the OpenMetadata server.
The workflow is modeled around the following
[JSON Schema](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-spec/src/main/resources/json/schema/metadataIngestion/workflow.json)

### 1. Define the YAML Config

This is a sample config for SFTP:

#### Source Configuration

Configure the source type and service name for your SFTP connector.

#### Host

**host**: SFTP server hostname or IP address.

#### Port

**port**: SFTP server port number. Defaults to `22`.

#### Authentication Type

**authType**: Choose between `basicAuth` (username and password) or `keyAuth` (SSH private key). See configuration examples below for both options.

#### Root Directories

**rootDirectories** (Optional): List of root directories to scan. Defaults to `/`.

#### Directory Filter Pattern

**directoryFilterPattern** (Optional): Regex to only include/exclude directories that match the pattern.

#### File Filter Pattern

**fileFilterPattern** (Optional): Regex to only include/exclude files that match the pattern.

#### Structured Data Files Only

**structuredDataFilesOnly** (Optional): When `true`, only catalog structured data files (CSV, TSV). Defaults to `false`.

#### Extract Sample Data

**extractSampleData** (Optional): When `true`, extract sample data from structured files (CSV, TSV). Defaults to `false`.

#### Source Config

Configure Drive metadata ingestion options for SFTP. SFTP ingests directories and files only, so spreadsheet and worksheet ingestion are disabled.

#### Sink Configuration

To send the metadata to OpenMetadata, it needs to be specified as `type: metadata-rest`.

#### Workflow Configuration

The main property here is `openMetadataServerConfig`, where you can define the host and security provider of your OpenMetadata installation.

* **loggerLevel**: Specify the logger level depending on your needs. If you are troubleshooting an ingestion, use `DEBUG` for more detailed traces.
* **JWT token**: JWT tokens allow clients to authenticate against the OpenMetadata server. See [Enable JWT Tokens](https://docs.open-metadata.org/deployment/security/enable-jwt-tokens) and [JWT Troubleshooting](https://docs.open-metadata.org/deployment/security/jwt-troubleshooting) for more information.
* **storeServiceConnection**: If set to `true` (default), sensitive information is stored encrypted with the Fernet Key or externally if you have configured a [Secrets Manager](https://docs.open-metadata.org/deployment/secrets-manager). If set to `false`, the service is created, but the service connection information is only used by the Ingestion Framework at runtime and is not sent to the OpenMetadata server.
* **SSL configuration**: If you have added SSL to the [OpenMetadata server](https://docs.open-metadata.org/deployment/security/enable-ssl), configure the certificates for ingestion. Set `verifySSL` to `ignore`, or set it to `validate` and provide `sslConfig.caCertificate` with a local path to the server certificate. See [SSL Troubleshooting](https://docs.open-metadata.org/deployment/security/enable-ssl/ssl-troubleshooting) for more information.
* **ingestionPipelineFQN**: Fully qualified name of the ingestion pipeline, used to identify the current ingestion pipeline.

sftp\_config.yaml
Copy full code

```yaml theme={null}
source:
  type: sftp
  serviceName: local_sftp
  serviceConnection:
    config:
      type: Sftp
      host: sftp.example.com
      port: 22
      authType:
        username: your_username
        password: your_password
      rootDirectories:
        - /data
      # directoryFilterPattern:
      #   includes:
      #     - /data/reports/.*
      #   excludes:
      #     - /data/temp/.*
      # fileFilterPattern:
      #   includes:
      #     - .*\.csv
      #     - .*\.tsv
      #   excludes:
      #     - .*\.tmp
      # structuredDataFilesOnly: false
      # extractSampleData: false
```

```yaml theme={null}
  sourceConfig:
    config:
      type: DriveMetadata
      markDeletedDirectories: true
      markDeletedFiles: true
      includeDirectories: true
      includeFiles: true
      includeTags: true
      includeOwners: false
      overrideMetadata: false
      useFqnForFiltering: false
      # directoryFilterPattern:
      #   includes:
      #     - /data/reports/.*
      #   excludes:
      #     - /data/temp/.*
      # fileFilterPattern:
      #   includes:
      #     - .*\.csv
      #     - .*\.tsv
      #   excludes:
      #     - .*_backup\.csv
      # SFTP ingests directories and files only.
      includeSpreadsheets: false
      includeWorksheets: false
      markDeletedSpreadsheets: false
      markDeletedWorksheets: false
      threads: 1
```

```yaml theme={null}
sink:
  type: metadata-rest
  config: {}
```

```yaml theme={null}
workflowConfig:
  loggerLevel: INFO  # DEBUG, INFO, WARNING or ERROR
  openMetadataServerConfig:
    hostPort: "http://localhost:8585/api"
    authProvider: openmetadata
    securityConfig:
      jwtToken: "{bot_jwt_token}"
    ## Store the service Connection information
    storeServiceConnection: true  # false
    ## Secrets Manager Configuration
    # secretsManagerProvider: aws, azure or noop
    # secretsManagerLoader: airflow or env
    ## If SSL, fill the following
    # verifySSL: validate  # or ignore
    # sslConfig:
    #   caCertificate: /local/path/to/certificate
# ingestionPipelineFQN: <service name>.<ingestion name> ## e.g., "my_redshift.metadata"
```

### Configuration Examples

#### Basic Authentication (Username/Password)

```yaml theme={null}
source:
  type: sftp
  serviceName: sftp_prod
  serviceConnection:
    config:
      type: Sftp
      host: sftp.example.com
      port: 22
      authType:
        username: sftp_user
        password: your_secure_password
      rootDirectories:
        - /data/exports
        - /data/reports
```

#### SSH Private Key Authentication

```yaml theme={null}
source:
  type: sftp
  serviceName: sftp_prod
  serviceConnection:
    config:
      type: Sftp
      host: sftp.example.com
      port: 22
      authType:
        username: sftp_user
        privateKey: |
          -----BEGIN OPENSSH PRIVATE KEY-----
          <your_private_key_content>
          -----END OPENSSH PRIVATE KEY-----
        # privateKeyPassphrase: your_passphrase  # only if key is encrypted
      rootDirectories:
        - /data
```

#### Configuration with File Filtering and Sample Data

```yaml theme={null}
source:
  type: sftp
  serviceName: sftp_analytics
  serviceConnection:
    config:
      type: Sftp
      host: sftp.example.com
      port: 22
      authType:
        username: sftp_user
        password: your_secure_password
      rootDirectories:
        - /data/analytics
      directoryFilterPattern:
        includes:
          - /data/analytics/sales/.*
          - /data/analytics/marketing/.*
        excludes:
          - /data/analytics/temp/.*
          - /data/analytics/archive/.*
      fileFilterPattern:
        includes:
          - .*\.csv
          - .*\.tsv
        excludes:
          - .*_backup\.csv
      structuredDataFilesOnly: true
      extractSampleData: true
```

### 2. Run with the CLI

First, we will need to save the YAML file. Afterward, and with all requirements installed, we can run:

```bash theme={null}
metadata ingest -c <path-to-yaml>
```

Note that from connector to connector, this recipe will always be the same. By updating the YAML configuration,
you will be able to extract metadata from different sources.

## Related

> [card] [Configure Ingestion Externally](https://docs.open-metadata.org/v2.1.x/deployment/ingestion.md)
>
> Deploy, configure, and manage the ingestion workflows externally.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.