Skip to content

SFTP server (sftp) ​

Signs in to an SSH server with the SSH credential the other SSH sensors use, starts the SFTP subsystem, and measures how long that takes. It can also look at one file (does it exist, how big, how old) or one folder (how many files, how big, how old is the newest). It reads only. The account may be limited to SFTP and chrooted; no shell is needed.

What it looks like ​

The page of a sftp sensor in the light theme

The page of an SFTP sensor after a few polls, counting the files of a folder for an SFTP-only account on a lab server. In the dark theme: the sensor's page. The form for adding it, with its parameters filled in: light, dark.

Channels ​

KeyNameUnitDefault limits
connect_msConnect time (TCP and key exchange)mswarning above 1000, error above 3000
login_msTime until SFTP is readymswarning above 3000, error above 8000
response_msResponse time (signing in and looking at the item)mswarning above 5000, error above 15000
existsExists (with item)error below 1 (0 is Missing, 1 is Present)
age_sAge (the file, or the newest file in a folder)swarning above 26 hours (93600), error above 48 hours (172800)
size_bytesSize (the file, or all counted files in a folder)Bnone
file_countFiles (folders only)error below 1

A missing file or folder is not a failed poll: it is a reading. exists is 0 and the age and size are unknown, so the default limit turns the sensor Down and the message says what was missing. A folder with no file in it, or none that matches the filter, gives file_count 0. That is the case of a backup that did not run. Only the files directly in a folder are counted, not those in its sub-folders. The age is measured from the last change time the server reports to the probe's clock, so a probe whose clock is wrong makes every age wrong; keep it on NTP. A file stamped in the future is as new as can be (age 0). The default limits suit a daily backup; change them on the sensor for anything else, as described for win_file.

Parameters ​

ParameterDefaultMeaning
port22TCP port of the SSH server.
itemnonefile or folder. Without item and path the sensor only signs in.
pathnoneThe file or folder, relative to where the login starts (the root of a chrooted account) or absolute. Needed with item.
filternoneFolders only. Count only the files whose name matches: * is any run of characters and ? is one, case ignored (*.bak). It is matched against the file name.

Suggested interval: 300 seconds. Credential: SSH (ssh_password or ssh_key).

Host key ​

As for the other SSH sensors, the first successful poll records the server's host key in the sensor's state, and a different key fails every later poll with SSH host key changed before any credential is sent. Choose "Forget stored state" in the sensor's settings after a deliberate change.

On the target ​

An account that may use the sftp subsystem and read the folder. In OpenSSH a chrooted SFTP-only account is Match User ... ChrootDirectory ... ForceCommand internal-sftp; give the sensor paths relative to the chroot.

Failures ​

MessageMeaning
a refused connection (kind unreachable), a timeout (kind timeout)The service is not listening or a firewall drops the traffic.
SSH host key changed: ... (kind protocol)The server presents another key than the recorded one.
... rejected the SSH credential for user ... (kind auth_failed)The user name, password or key is wrong.
SFTP start failed (does the server run the sftp subsystem?) (kind protocol)SSH works but SFTP is not enabled for the account.
the server refused ...: permission denied (kind protocol)The account cannot read the path.

Testing ​

The live tests in crates/probeward-sensors/tests/mail_ftp_live.rs need PROBEWARD_TEST_SFTP_HOST, PROBEWARD_TEST_SFTP_USER, PROBEWARD_TEST_SFTP_PASSWORD and PROBEWARD_TEST_SFTP_FOLDER (a folder of the account holding file-0d.txt, file-1d.txt, file-7d.txt and file-30d.txt), and skip cleanly without them. They check the folder count, the ages of the four files, a missing file and folder, the recorded host key and a wrong password.

AGPL-3.0-only