Skip to Content
IntegrationsSFTP / FTP

SFTP / FTP

Collection SFTP_ARQUIVO and Delivery SFTP_UPLOAD. It is file-based integration for when the folder is on a remote server — the supplier that leaves the file on an SFTP, the legacy system that only publishes over FTP. When the folder is local or mounted on the CMS server, the path is the File Connection.

The two live together in the Files category of the Connections screen, but they are separate types: SFTP / FTP has host, user and protocol; File is just a directory. Collection and Delivery have the same options in both. When the folder is a bucket (Amazon S3, Azure Blob, Google Cloud Storage), the Collection and the Delivery are these same ones — see Cloud storage.

Connection

SFTP / FTP connection: protocol, credential, fingerprint and base folder
SFTP / FTP connection: protocol, credential, fingerprint and base folder
SFTP / FTP connection: protocol, credential, fingerprint and base folder
FieldWhat it is for
ProtocolSFTP (SSH), Explicit FTPS (AUTH TLS), Implicit FTPS or FTP (unencrypted)
Host / PortServer. Empty port = 22 on SFTP, 21 on FTP and explicit FTPS, 990 on implicit FTPS
Username / PasswordServer credential. With a private key, the password can be empty
Private key (optional) / Key passphraseSFTP only: key authentication, in OpenSSH or PEM format
Server fingerprintSFTP only: the SHA256 of the server key, as shown by ssh-keygen -lf
Validate TLS certificate / CA certificateFTPS only: CA that signs the server certificate, when it is not public
Base folder on the serverCollection subfolders and Delivery paths are relative to it and cannot leave it. Empty = the user’s home folder
Timeout (ms)Maximum time for connecting and for each operation

Plain FTP sends username, password and files in clear text over the network. The screen warns when you pick that protocol. Use it only on an isolated network; prefer SFTP or FTPS.

Pinning the server fingerprint

On SFTP, the fingerprint is what keeps a fake server in the path from receiving the password:

  1. Leave the Server fingerprint field empty and click Test Connection. The result shows the server key (SHA256:...).
  2. Check that value with the server administrator.
  3. Paste it into the field and save. From then on the connection only opens with that server.

If the server is replaced later, the connection fails saying the expected and the received fingerprint. A planned replacement: update the field. A replacement nobody asked for: investigate first.

Collection — SFTP_ARQUIVO

The options are the same as the folder Collection (FILE_WATCH) — see Files:

FieldWhat it is for
Watched SubfolderRelative to the connection’s base folder. Blank = the base folder itself
File Mask*.csv;*.txt, accepts * and ?
Include subfoldersAlso scans the subfolders
EncodingUTF-8, Latin-1, UTF-16 LE, ASCII or Binary (Base64)
Emission ModeWhole file (one message) or One message per line
Skip first lineSkips the header in one-message-per-line mode
Include metadataEnvelope with the file’s name, path and dates
Scan Interval (ms)Defaults to 30 seconds — each scan opens a session on the remote server
Stability (ms)The file is only read after staying this long without a size change
Maximum Size (KB)Above that, the file goes to the error folder
Action After ReadingMove to processed, rename with a suffix, delete or none
Error FolderWhere the file that could not be read or stored goes

Before reading, the file is renamed on the server to <name>.cms-processando — the same lock as the folder Collection, which prevents two reads of the same file. Each cycle opens one session on the server and closes it at the end.

Delivery — SFTP_UPLOAD

Same fields as the file Delivery:

FieldWhat it is for
File Path/NameRelative to the connection’s base folder. Accepts payload {{alias}} (output/{{orderNumber}}.json)
EncodingAs in the Collection
Write ModeCreate new (fails if it already exists), Overwrite or Append
Create directoryCreates the destination folder on the server when it does not exist yet
Atomic writeUploads to a .tmp and renames at the end, so whoever watches the remote folder never reads a half-written file
File Content TemplateWhat goes inside the file; empty writes the payload as it arrived

As in the file Delivery, the path resolves against the original payload (before the Transformer) and the Content Template against the already transformed payload — see Content Model.

Common errors

MessageLikely cause
“The server refused the credentials”Wrong user, password or key
“The private key could not be read”Format other than OpenSSH/PEM, or wrong passphrase
“The server key does not match the pinned fingerprint”The server changed — or there is a fake server in the path
“The FTPS server TLS certificate could not be validated”Internal CA: paste it into CA certificate
“Could not connect to the file server”Host, port, protocol or firewall. On FTP, also check that the passive-mode ports are open
“Path … must be relative and stay inside the connection base folder”Absolute path, or one with ..
“Path … does not exist on the server”Nonexistent subfolder or base folder
“The user has no permission on …”Missing read, write or rename permission on the folder
“File … already exists on the server and the write mode is Create new”Use a unique name (with {{alias}}) or another write mode

Testing in the Test Bench

In the Test Bench, the Publish to source mode uploads a stimulus file to the folder the Collection scans, with a name that matches the mask, and lets the Collection find it on the next scan.