SFTP delivery
On this page

This page is for version 1.0. Read the current version.

SFTP delivery

The SFTP channel uploads a feed to an SFTP server instead of, or as well as, publishing it on the store. Google Merchant Center accepts feeds this way, and so do most marketplaces and price comparison services.

An SFTP connection is a record of its own, shared by every feed that uploads to the same server; saving it connects it. The store owner makes it and points a feed at it in the admin, with a screenshot a step: the manual's SFTP connections and, for Google Merchant Center's server, The SFTP channel. This page has what the manual leaves to you: key authentication, why a save is refused, the host-key fingerprint, the upload and the transfer limits.

The connection form

From a feed form whose channel is SFTP, + next to the connection picker opens the same form in a panel.

Field What to enter
Name Your own name for the connection: Warehouse SFTP, Google Merchant Center.
Host The server's host name or IP address, with no sftp:// in front.
Port 22 unless the server says otherwise. Google Merchant Center uses 19321.
Username The SFTP login.
Authentication Password or Private key.
SHA-256 host-key fingerprint The server's SSH host-key fingerprint; see Find the host-key fingerprint.
Password For password authentication. On a later edit, leaving it blank keeps the stored password.
Private key, Private-key passphrase For key authentication: the private key and its passphrase, if it has one. Choose a key file reads the key from its file in the browser; the form then names the file and the kind of key (OpenSSH, PEM or PuTTY), never the key itself. A public key (.pub) or a file that is no key is refused on the spot. Paste the key instead opens a box for a key that is not in a file. On a later edit, leaving them empty keeps the stored ones.

Saving connects the connection: the module reaches the server, compares its host key with the fingerprint and logs in. Saving a change to its host, port, username, authentication, fingerprint or any secret connects it again; renaming it does not.

Test Connection, on a connected connection's form, checks it again as stored, as Connect does on one that is not connected. A failure marks it Failed, and its feeds deliver nothing until it connects again: a delivery checks the stored status before it calls the server, so the retries fail with Connect the selected SFTP connection before using it on a feed. and do not reach it. An upload that fails leaves the status as it was.

When the save is refused

The connection is saved all the same, as Failed, and no feed delivers through it until a save or Connect gets in. The reasons:

Message Cause
Could not connect to the SFTP server. Check host, port and network access. Wrong host or port, or the Magento server cannot reach the SFTP server: a firewall, or an IP allow-list the Magento server is not on.
The SFTP server host key could not be read or verified. Check that host and port point to the expected server. The handshake dropped, or the server's signature did not verify against its key.
SFTP server host-key fingerprint does not match the configured SHA-256 fingerprint. The fingerprint is wrong, or the server's key changed. Read it again; see Find the host-key fingerprint.
SFTP authentication failed. Check the username and authentication credentials. Wrong username, password or key.
The private key could not be loaded. Check the key and its passphrase. What was pasted or chosen is not a private key, a pasted public key among them, or its passphrase is wrong.

Behind Could not connect to the SFTP server and The SFTP server did not answer within …, var/log/arlanix.log has a warning, Connecting to SFTP server sftp.example.com:22:, with phpseclib's reason: a refused connection, a host name that does not resolve, or no key exchange the two sides share.

The upload

Remote file name or path is a bare file name, google-shopping.csv, for the account's root directory, which is what Google Merchant Center expects; or an absolute path, /feeds/google-shopping.csv, for a server of your own. The directory must already exist.

Where the server can rename a file over another in one step, as OpenSSH servers do, the file is uploaded under a temporary name and renamed into place, so the server never sees a half-written feed. The temporary name is the destination's own, .<name>.arlanix-feed.tmp, so what an upload cut short left there is overwritten by the next one. Google Merchant Center's server cannot, so there the file is written under its own name, in a single upload.

When the server is slow or down

A delivery waits on the server for a limited time, so one feed whose server stops answering cannot hold up the others in the same cron run. By default it allows 10 seconds to reach the server, agree the keys and log in, 30 seconds for any one answer after that, and an average upload speed of 50 KB a second, with at least a minute for any file.

For a server that is far away or a link that is slow, raise the limits under Stores → Configuration → Arlanix → Developer → SFTP delivery; the arlanix_feed_sftp/transfer/* rows of Settings name them.

The run fails with what happened:

Message Cause
The SFTP server did not answer within 10 seconds. Check that it is up and reachable. The server accepted the connection and then said nothing, or answered too slowly to log in.
The SFTP server stopped answering: nothing came back within 30 seconds. The session went quiet during the upload.
The upload to the SFTP server was too slow: it did not finish within 205 seconds, at 50 KB a second at least, and was given up. The upload went on, but slower than minimum_speed.
Not tried: the SFTP server sftp.example.com:22 did not answer less than a minute ago. The next run tries again. Another feed on the same server could not reach it less than a minute before, in the same cron run, so this one was not made to wait as long again.
SFTP upload failed. The server answered: NET_SFTP_STATUS_PERMISSION_DENIED: Permission denied The server refused to write the file, or to rename it into place, and gave this reason, as phpseclib words it. Without a reason the message ends at SFTP upload failed.
The upload to the SFTP server was cut short: the server has 33554432 of the file's 41943040 bytes. The published file was left as it was. Before the rename, the size the server holds under the temporary name is compared with the file's. It held less, as when the server stops taking writes part way, out of space or over a quota, so the file was not renamed into place.

Where the server renames atomically, a given-up upload leaves the published file as it was. Where it writes in place, as Google Merchant Center's does, the file may be left half-written until the next delivery replaces it. A failed feed is tried again later, each failure in a row waiting longer: see When a run fails.

Find the host-key fingerprint

Every SSH server identifies itself with a host key. Before logging in, the module computes the SHA-256 fingerprint of the key the server presents and compares it with the one stored on the connection. If they differ, nothing is sent. This is what stops a feed, and the password with it, from going to a server that only pretends to be yours.

The field takes the OpenSSH form of a SHA-256 fingerprint: SHA256: followed by 43 characters, for example:

SHA256:glAmvVKxBWXcUTPHGNA5+R0Oz/qOkA0MwZ1yJB8FeK4

Spaces around or inside the value, and a trailing =, are dropped when the connection is saved, and the 43 characters given alone get SHA256: in front of them. An MD5 fingerprint (85:19:8a:fb:…) is not accepted.

Google Merchant Center

Merchant Center shows its SFTP server, port, username and fingerprint when a data source is added with Add a file using SFTP or Google Cloud Storage: the manual's The SFTP channel shows each step. It prints the fingerprint as SHA256: +0f4…, with a space after the colon; it is taken as it is, or as the characters after SHA256: alone.

Any other server

Ask whoever runs the server for the SHA-256 fingerprint of its host key; a hosting provider or marketplace usually publishes it next to the SFTP credentials.

If you can reach the server from a computer with OpenSSH (any Mac or Linux machine, or Windows with OpenSSH installed), read the fingerprint yourself:

ssh-keyscan -p PORT HOST 2>/dev/null | ssh-keygen -lf -

Replace PORT with the server's SSH port, 22 unless the server says otherwise, and HOST with its host name.

It prints one line per key the server offers, for example:

256 SHA256:glAmvVKxBWXcUTPHGNA5+R0Oz/qOkA0MwZ1yJB8FeK4 sftp.example.com (ED25519)
4096 SHA256:2rK+thAm1pVGMIeacFuBB9ZP9xziD78DBgdz5q4Xmu0 sftp.example.com (RSA)

The module checks the key it negotiates with the server. When the server offers several, that is the first of these it supports: ED25519, then ECDSA, then RSA. In that example output, enter the ED25519 line.

On a server you administer, the same fingerprints come from the keys themselves:

ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub

Confirm a fingerprint read over the network with the server's owner, or with the value printed on the server, before saving it: a fingerprint accepted blindly protects nothing. When the server replaces its host key, verification fails until the field is updated.