> AI agents: this is one page from Mammoth Analytics documentation. The index of all pages as Markdown is https://docs.mammoth.io/llms.txt. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get Markdown.

# SFTP connector

> Connect Mammoth to an SFTP server using a password, a Mammoth-generated SSH key, or your own private key, then import a file and set up refreshes.

The SFTP connector imports files from any SFTP-compatible file server into Mammoth as a dataset. Mammoth supports three authentication methods: **username & password**, **SSH key generation** (Mammoth-hosted), and **private key authentication** (user-provided). Supports a wide range of file formats including CSV, Excel, and compressed archives.

## Before you start

You need:

- An SFTP server accessible from the internet
- A user account with read access to the files you want to import
- Your server's hostname or IP address and port (default: 22)
- Mammoth's IP address added to your server's firewall allowlist (shown in the connection form)
- One of three authentication methods:
  - **Username & password**—Your SFTP user's password
  - **SSH Key**—Mammoth generates a public key that you add to your server
  - **Private Key**—Your existing SSH private key in PEM format

## Step 1: Select the SFTP connector

1. In Mammoth, go to **Data Library** and click **+ New Dataset**
2. Select **Connectors**
3. Search for **SFTP** or find it in the **Cloud Storage** category
4. Click the **SFTP** tile

## Step 2: Create a connection

Click **New Connection** and select an authentication method. The SFTP connector supports three authentication approaches:

### Method 1: Username & password

Select **Username & Password** for straightforward password-based authentication.

![SFTP New Connection form with Username & Password selected and Host, Port 22, Username, Password, and Display Name fields](https://docs.mammoth.io/api/v1/images/20260826_102031_Screenshot2026-05-221822431.jpg)

| Field | Description | Example |
| --- | --- | --- |
| **Host** | Hostname or IP address of your SFTP server | `sftp.example.com` |
| **Port** | SFTP port | `22` (default) |
| **Username** | SFTP user with read access | `mammoth_user` |
| **Password** | Password for the SFTP user |—|
| **Display Name** | Optional label for this connection | `SFTP Production` |

Fill in the fields and click **Connect**.

### Method 2: SSH key (Mammoth-generated)

Select **SSH Key** to have Mammoth generate a unique SSH public key that you'll add to your server. This method has no private key to manage—only the public key you install on the SFTP server.

![SFTP New Connection form with SSH Key selected, showing Host, Port, Username, Display Name, and Generate SSH Key button](https://docs.mammoth.io/api/v1/images/20260826_102052_Screenshot2026-05-221824461.jpg)

| Field | Description |
| --- | --- |
| **Host** | Hostname or IP of your SFTP server |
| **Port** | SFTP port (default: 22) |
| **Username** | SFTP user with read access |
| **Display Name** | Optional label for this connection |

After filling in the fields, click **Generate SSH Key**. Mammoth creates a unique public key and displays it. Click **Copy SSH Key** or **Download key**, then add it to your SFTP server's `~/.ssh/authorized_keys` file (on the line for your SFTP user). Once the key is installed on the server, return to Mammoth and click **Back to Existing Connections**, then select the connection to continue.

> **Tip: Downloading the SSH public key.**
> On the key screen, you can copy the key to your clipboard with **Copy SSH Key** or download it as a `.pub` file with **Download key** for easy transfer to your server.

### Method 3: Private key (user-provided)

Select **Private Key** if you already have an SSH private key and want Mammoth to use it for authentication.

![SFTP New Connection form with Private Key selected, showing Host, Port, Username, Display Name, and PEM key text area](https://docs.mammoth.io/api/v1/images/20260826_102123_Screenshot2026-05-221825101.jpg)

| Field | Description |
| --- | --- |
| **Host** | Hostname or IP of your SFTP server |
| **Port** | SFTP port (default: 22) |
| **Username** | SFTP user with read access |
| **Private Key (PEM format)** | Your SSH private key in PEM format (`-----BEGIN RSA PRIVATE KEY-----` ... `-----END RSA PRIVATE KEY-----`) |
| **Passphrase** | Optional passphrase for the private key (if your key is encrypted) |
| **Display Name** | Optional label for this connection |

Paste your private key directly in the **Private Key (PEM format)** text area, or click **Upload key file** to select a `.pem` or `.key` file from your computer. If your key is passphrase-protected, enter the passphrase. Click **Connect** to save the connection.

> **Warning: Private key security.**
> Never share your private key or commit it to version control. If you believe your key is compromised, remove it from your SFTP server's authorized keys immediately.

---

### SFTP firewall note

The connection form shows a message at the bottom: "Mammoth connects from IP [address]. Add it to your server's allowlist if needed." Allow that IP through your firewall for the connection to succeed.

## Step 3: Select your SFTP file

After connecting, select the connection under **Existing Connections**, then browse to the file on the SFTP server using the file browser.

### Supported SFTP file formats

`.txt` · `.csv` · `.tsv` · `.psv` · `.xls` · `.xlsx` · `.zip` · `.bz2` · `.gz` · `.tar` · `.7z`

### Choose a future pulls mode

After you select a file, a **Future pulls mode** list appears:

- **Pull same file**—Every refresh re-reads the file you selected
- **Pull next file based on name pattern**—Available only when a single file is selected. Every refresh looks for the next file that matches a date pattern in the file name. Choose the **Folder to pull from** and enter a **File pattern**. For example, for the file `sftp_Tue-01-November-2022_daily.csv` the pattern is `sftp_<dy>-<dd>-<mon>-<yyyy>_daily.csv`

In a file pattern, put a date format inside `<>`. The supported formats are `dd`, `mm`, `yyyy`, `yy`, `month`, `mon`, `day`, `dy`, `hh`, `mi`, and `ss`, in full lower case, upper case, or capitalized. The selected file name must contain at least one date format, and the pattern must match the selected file name.

If the file is an Excel workbook (`.xls`/`.xlsx`), also enter the **Exact Sheet name** to import.

![SFTP New Dataset dialog with Exact Sheet name, Future pulls mode set to name pattern, Folder to pull from, and File pattern](https://docs.mammoth.io/api/v1/images/20260826_102259_Screenshot2026-05-221846531.jpg)

## Step 4: Create the SFTP dataset

Click **Create new dataset**. Mammoth does not ask you to choose an update method for this connector.

## Keep SFTP data up to date

For files that update regularly on your SFTP server, set up a **Dataset Refresh** automation. When the automation runs, Mammoth re-reads the file from the SFTP server.

If your SFTP server delivers files with date-stamped names (for example, `orders_20240115.csv`), choose **Pull next file based on name pattern** when you create the dataset so each refresh picks up the next matching file.

## Troubleshoot SFTP connections

### Connection fails

- Confirm port 22 (or your custom port) is open inbound from Mammoth's IP address (shown on the connection form)
- Verify the host, port, and username are correct
- For **Username & Password**: confirm the password is correct
- For **SSH Key**: verify the public key is installed at `~/.ssh/authorized_keys` on the server under the SFTP user's home directory
- For **Private Key**: confirm the key is in valid PEM format and the passphrase (if set) is correct; verify the corresponding public key is in `~/.ssh/authorized_keys` on the server

### Permission denied on file

- The SFTP user must have read access to the target file and list access to the containing directory
- Check file permissions with `ls -la` on the server, and adjust with `chmod` if needed

### Invalid private key format

The error "Invalid private key format. Please provide a valid PEM-encoded key." means Mammoth could not read the key:

- Ensure the private key is a PEM-encoded key (it begins with a `-----BEGIN ... PRIVATE KEY-----` line)
- Check that the entire key, including the `-----BEGIN` and `-----END` lines, is pasted into the form
- Uploaded key files can't exceed the maximum allowed size for an SSH private key (16 KB); Mammoth shows "File exceeds the maximum allowed size for an SSH private key."

---
Source: https://docs.mammoth.io/learn/connectors/sftp.md · Updated: 2026-10-13