Skip to content

Configuration

uFTP is configured with one file, uftpd.cfg. The server reads ./uftpd.cfg (the directory you start it from) if that file exists, otherwise /etc/uftp/uftpd.cfg. Lines that start with # are comments. Restart uFTP to apply a change.

The sample file shipped with the source (uftpd.cfg) describes every option. Defaults apply when an option is omitted. The sample configuration sets some options explicitly.

Server

Option Default Meaning
FTP_PORT 21 TCP port of the control connection. Use a port above 1024 to run without root.
SINGLE_INSTANCE false Set to true to allow only one server at a time. The lock file is /run/uftp/uFTP.pid; the running user needs permission to create /run/uftp if it does not exist.
DAEMON_MODE false Set to true to run in the background. Keep false when running from a console or with systemd.
RESPAWN_PROCESS true A supervisor process restarts the server if it stops. Every restart is logged. Set false with systemd.

Connections and limits

Option Default Meaning
MAXIMUM_ALLOWED_FTP_CONNECTION 10 Maximum number of clients together. See Memory.
MAX_CONNECTION_NUMBER_PER_IP 4 Connections from one address together (0 = no limit).
MAX_CONNECTION_PER_ACCOUNT 0 Sessions of one user from any address (0 = no limit). MAX_CONNECTION_PER_ACCOUNT_n sets the limit of USER_n alone.
MAX_CONNECTION_RATE_PER_IP 0 New connections per minute from one address (0 = no limit). The ones over the limit get 421. An IPv6 address counts as its /64 network.
MAX_CONNECTION_TRY_PER_IP 3 Failed logins before the address is blocked for 5 minutes (0 = no limit). An IPv6 address counts as its /64 network.
IDLE_MAX_TIMEOUT 3600 Seconds of inactivity before a client is disconnected (0 = never).
LOGIN_TIMEOUT 60 Seconds a client may stay connected without logging in (0 = no limit). NOOP does not extend it.
MAX_DOWNLOAD_SPEED, MAX_UPLOAD_SPEED 0 Speed limit in KB/s for the users that have no value of their own (and for PAM users). 0 = no limit. See Speed limits.
SITE_COMMAND_<name> off A program that SITE RUN <name> can start (absolute path, executable, not writable by others). See Run scripts.
SITE_COMMAND_OUTPUT_DIR_<name> unset Optional absolute directory for the job's .out and .err files. Must exist and be writable by uFTP. If outside the user's FTP home, the user cannot fetch these files over FTP. See Run scripts.
SITE_COMMAND_TIMEOUT_SECONDS, SITE_COMMAND_MAX_OUTPUT_MB, SITE_COMMAND_MAX_PARALLEL 600, 1024, 2 Time limit of a job (1 to 86400 s), size limit of each of its output files (MB), jobs at the same time in the server (1 to 16; one per user).
AUTH_HOOK off A program that checks the users the configuration does not know (database, LDAP, API). See Authentication hook.
AUTH_HOOK_TIMEOUT_SECONDS, AUTH_HOOK_MAX_PARALLEL 5, 4 The hook is killed after this many seconds (1 to 60); this many may run at the same time (1 to 32).
SHUTDOWN_GRACE_SECONDS 30 After SIGTERM or SIGINT the server stops accepting connections, closes the idle clients (421) and waits up to this many seconds for the transfers in progress. 0 = stop at once.
HEALTH_PORT, HEALTH_LISTEN_ADDRESS 0, 127.0.0.1 HTTP pages for the tools that watch the server. See Watch the server. 0 = off.
CONTROL_SOCKET off The local socket of uftpctl. See Watch the server.
UMASK not set Octal, 000 to 077: the permissions that new files and directories do not have (027 = files 640, directories 750). UMASK_n is the one of a user. Not set = the umask of the process.
HASH_MAX_SIZE_MB 256 The biggest file HASH, XCRC, XMD5, XSHA1 and XSHA256 work on (they run in a thread of their own, so the other connections do not wait). A bigger file is answered 552. 0 = the commands are off and not announced in FEAT.
MIN_FREE_SPACE_MB 0 STOR and APPE are refused (452) when the free space of the disk is below this many megabytes, and an upload in progress is stopped. 0 = no check. 1024 or more is reasonable, because the server runs as root.

FileZilla and the limits

FileZilla with 10 simultaneous transfers uses 11 sessions at once, and it can open about 18 connections in a few seconds. Set MAX_CONNECTION_NUMBER_PER_IP and MAX_CONNECTION_RATE_PER_IP accordingly if your users transfer many files together.

Memory

A slot that is not used takes about 1 KB: 10,000 slots are about 12 MB (in 4.3.0 they were about 385 MB, because the memory of every slot was reserved at start). The memory of a connection is made when it is accepted and given back when it ends: about 21 KB for a connection in clear text, about 29 KB with TLS (the TLS objects are made when AUTH TLS or a protected data connection needs them). So a server with 12,000 slots and 100 clients takes about 15 MB. The limit still decides how many connections the server accepts: set MAXIMUM_ALLOWED_FTP_CONNECTION to what you need.

Passive mode and NAT

Option Default Meaning
RANDOM_PORT_START, RANDOM_PORT_END 10000, 50000 Range of the ports used for passive data connections. Forward the same range on your router.
SERVER_IP (not set) The address that PASV tells the clients, with commas: 192,168,1,1. Needed when the server is behind a NAT.
PASV_PROMISCUOUS false By default a data connection must come from the same address as the control connection (RFC 2577). Set true only behind NAT pools that use several outgoing addresses.

More in Behind a NAT or a firewall.

TLS

Option Default Meaning
CERTIFICATE_PATH cert.pem The certificate. The sample sets this to /etc/uftp/tls/cert.pem.
PRIVATE_CERTIFICATE_PATH key.pem The private key. The sample sets this to /etc/uftp/tls/key.pem.
TLS_KEY_PASSWORD_FILE none The file with the password of the private key, if the key is protected by one: its first line, read once at start. See TLS and certificates.
FORCE_TLS false Require TLS for login. Clients use PROT P to encrypt file transfers.
TLS_MIN_VERSION 1.2 The lowest TLS version offered: 1.2 or 1.3. TLS 1.0 and 1.1 are never offered.
TLS_CIPHERS HIGH:!aNULL:!MD5 The ciphers of TLS 1.2 and lower, an OpenSSL cipher list (openssl ciphers -v).
TLS_CIPHERSUITES OpenSSL's The cipher suites of TLS 1.3 (OpenSSL 1.1.1 or later), for example TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256.
TLS_REQUIRE_SESSION_REUSE true A data connection must resume the TLS session of the control connection, or it is refused with 522. The session of another connection does not count. Set to false for clients that cannot resume sessions.

Needs a build with OpenSSL. See TLS and certificates. A value that is not valid in the four TLS_ options stops the server at start, with a message that names the option.

TLS_REQUIRE_SESSION_REUSE is enabled by default. In FTPS every transfer opens a second connection, and its TLS handshake can resume the session of the control connection, which proves it is the same client. With the option on, a data connection that starts a new session, or that resumes the one of another control connection, is refused (and written to the log as a security event): somebody who reaches the passive port before the client cannot use the connection. The cost is that clients that do not resume sessions cannot transfer; FileZilla and most clients do resume.

Logs

Option Default Meaning
LOG_FOLDER Working directory Directory for daily uftpLog_YYYY-MM-DD files. The sample sets this to /var/log/uftp/.
MAXIMUM_LOG_FILES 30 Number of days to keep daily log files. Set to 0 to disable daily log files. Syslog, standard error logging and the transfer log are configured separately. Fatal errors can still be written to standard error.
SYSLOG_ENABLED false Every line also goes to syslog, with the identity uftp.
SYSLOG_FACILITY ftp Facility of syslog: ftp, daemon, auth, authpriv, user, or local0 to local7. Another name stops the server at start.
LOG_TO_STDERR false Every line also on stderr, with its time (journalctl, docker logs). In daemon mode stderr is closed.
XFERLOG_FILE none File of the transfer log: one line for each file sent or received, in the standard xferlog format. Not set = no transfer log.

In the same folder uFTP keeps uftpLog.current, a link to the file of today that moves to the new file when a new day starts. Programs that follow a log (see fail2ban) should use this name, because the name of the file changes every day. A link that you put in the place of the file of the day is not followed.

syslog, stderr and the transfer log

All of these are off by default, and the log files stay as they are.

syslog. With SYSLOG_ENABLED = true every line also goes to syslog (the identity is uftp, with the process id). The priority is the one of the kind of line: fatal errors are crit, errors err, security events (failed logins, blocks) warning, and accesses and information info. syslog adds its own time, so the line has no time and no place in the source. Read them with journalctl -t uftp. With MAXIMUM_LOG_FILES = 0 the lines go only to syslog.

stderr. With LOG_TO_STDERR = true every line also goes to stderr, with its time. Under systemd they are in the journal (journalctl -u uftp), and in a container in docker logs. A fatal error at startup is always written on stderr, also with this option off.

The transfer log. With XFERLOG_FILE = /var/log/xferlog uFTP writes one line for every file sent or received, in the xferlog format of wu-ftpd that tools such as logwatch and xferstats read:

Sat Nov 21 10:38:50 2026 0 203.0.113.7 5 /real.txt b _ i r username ftp 0 * c
Field Meaning
Sat Nov 21 10:38:50 2026 when the transfer ended (local time)
0 seconds the transfer took
203.0.113.7 address of the client (an IPv4 address that came on an IPv6 socket is shown as IPv4)
5 bytes transferred
/real.txt the path as the user sees it, from the home of the user. Spaces and control characters become _, so the line always has the same fields
b binary (uFTP always sends the bytes as they are)
_ no special action
i / o i = received from the client (upload), o = sent to the client (download)
r a real (configured) user
username the user
ftp 0 * service, no authentication method, no user id
c / i c = complete, i = incomplete: the transfer failed, and the bytes are what had been transferred

The file is created with mode 640 and opened for each line, so a rotation with logrotate is followed without a signal:

/var/log/xferlog {
    weekly
    rotate 8
    compress
    missingok
    notifempty
}

The normal log of uFTP keeps recording the same transfers, with the full path of the server. Deleting a file (DELE) is not in the transfer log.

The log records startup, crashes (with a stack trace), restarts, the reason of a shutdown, logins, transfers, file changes, and why each connection was closed. Characters that are not printable in a user name or a path are shown as ?.

Users

Every user has a number n in the names of its options. The numbers need not be consecutive, and the users are read in increasing order: USER_0, USER_2 and USER_10 are three users. Every USER_n needs PASSWORD_n and HOME_n; an option of a number that has no USER_n in the same file (a PERMISSIONS_5 with no USER_5) stops the server, because it would belong to nobody.

Option Required Meaning
USER_n yes The user name.
PASSWORD_n yes The password, or a hash (below). Needed by every USER_n.
HOME_n yes The directory the user can see. The user cannot leave it. Needed by every USER_n.
GROUP_NAME_OWNER_n no Group of the new files, an existing group of the system.
USER_NAME_OWNER_n no Owner of the new files, an existing user of the system. If it does not exist the files belong to root and the log says so at startup.
BLOCK_USER_n no A name that is never allowed to log in, also with PAM and the hook. The sample files and the package have BLOCK_USER_0 = root: with PAM, root over FTP would be the whole system. Remove it only if you need it (a device with no other user).
USERS_FILE no Not a user: a file with more users, see Users in a file of their own.
PERMISSIONS_n no What the user may do, see Permissions of a user. Default: everything.
ALLOW_FROM_n, DENY_FROM_n no From where the user may log in: addresses and networks, IPv4 and IPv6, with commas (192.168.1.0/24,2001:db8::/32). With ALLOW_FROM only from there; DENY_FROM wins. From elsewhere the answer is the one of a wrong password. A value that is not valid, or empty, stops the server at start. Behind a proxy the address is the one of the proxy.
UMASK_n no The UMASK of this user.
READ_ONLY_n no Defaults to false. true = the same as PERMISSIONS_n = list,download; do not set both options.
USER_0 = alice
PASSWORD_0 = a-long-secret
HOME_0 = /srv/ftp/alice
USER_NAME_OWNER_0 = alice
GROUP_NAME_OWNER_0 = alice

USER_1 = web
PASSWORD_1 = another-secret
HOME_1 = /var/www/html/
USER_NAME_OWNER_1 = www-data
GROUP_NAME_OWNER_1 = www-data

BLOCK_USER_0 = guest

If the owner options are missing, new files belong to the user and group of the server, usually root:root. Both owner options are needed: with only one of them, neither applies.

Permissions of a user with an owner

With an owner configured, uFTP checks what the user can do with a file the way the system does, one class only:

The file What the user gets
belongs to the configured owner full access (the owner could change the mode anyway)
has the configured group, and another owner the group bits of the file (r, w)
anything else the other bits of the file

Creating, deleting and renaming also need to write the directory (DELE, RMD, RNFR, RNTO, STOR, MKD). Only the owner root (user 0) has full access: the group root gives the group bits, like any other group.

A 0600 file is then not readable by somebody who only has its group, and a 0640 file is not writable by them. Without an owner the user has full access inside the home.

Giving the new files to the owner (chown) needs root. If uFTP runs as a normal user and an owner other than that user is configured, the server says so at startup and in the log; the uploads still work and the files stay with the user that runs uFTP.

Permissions of a user

By default a user may do everything inside the home. PERMISSIONS_n is a list of what the user may do, with commas and no spaces; the word all means everything and none nothing (the user can log in and move around, and nothing else). READ_ONLY_n = true is a shortcut for list,download; use one of the two, not both.

Permission Allows
list LIST, NLST, MLSD, MLST, and STAT of a path
download RETR
upload STOR and APPE of a file that does not exist yet
overwrite STOR and APPE of a file that exists
delete DELE and RMD
rename RNFR and RNTO
mkdir MKD
chmod SITE CHMOD
run SITE RUN and SITE STATUS (see Run scripts). Not part of all: it is given by name, PERMISSIONS_n = all,run.

SIZE and MDTM need list or download. HASH, XCRC, XMD5, XSHA1 and XSHA256 need download, and MFMT needs overwrite. Moving around (CWD, CDUP, PWD) is always allowed.

USER_0 = camera
PASSWORD_0 = a-long-secret
HOME_0 = /srv/ftp/camera/
PERMISSIONS_0 = upload,mkdir          # a drop box: it sends files, and can neither read, list nor delete

USER_1 = customer
PASSWORD_1 = another-secret
HOME_1 = /srv/ftp/customer/
READ_ONLY_1 = true                    # it only downloads

A command that is not allowed is answered 550 Permission denied: this account can not ... (a transfer is refused before the 150) and is written to the log. A name that is not a permission, a READ_ONLY_n that is not true or false, or both options together stop the server at start with a message that names the option. An empty value counts as not set (the reader of the configuration drops it), so the user may do everything: to forbid everything write none. The users of the system (PAM) have no permissions in the configuration and may do everything. The permissions come on top of the permissions of the files of the system (see USER_NAME_OWNER_n): both must allow.

Stopping the server

SIGTERM (systemctl stop, docker stop, kill) and SIGINT (Ctrl-C) stop uFTP in order:

  1. it stops accepting connections (a new client is refused at once);
  2. the clients that are not transferring are told 421 Service not available, the server is stopping. and closed;
  3. the uploads and downloads in progress go on to the end;
  4. it exits with status 0 when none is left, or after SHUTDOWN_GRACE_SECONDS (default 30): the transfers still going on are then cut.

A second SIGTERM or SIGINT stops it at once, and SHUTDOWN_GRACE_SECONDS = 0 gives the behaviour of 4.3.0 and before. With RESPAWN_PROCESS the supervisor passes the request on and exits when the server has stopped: it does not restart it. Make the service manager wait at least as long as the grace: TimeoutStopSec= in the systemd unit (the default is 90 s) and docker stop -t 40 (the default is 10 s) or stop_grace_period: 40s in Compose. After kill -9 or a crash nothing is waited for, of course.

Speed limits

MAX_DOWNLOAD_SPEED and MAX_UPLOAD_SPEED (KB/s, 1 KB = 1024 bytes) limit each user, and MAX_DOWNLOAD_SPEED_n and MAX_UPLOAD_SPEED_n next to USER_n limit one user and win over them. 0 means no limit, also to free one user from a global limit. All off by default.

MAX_DOWNLOAD_SPEED = 2048       # everybody: 2 MB/s down...
MAX_UPLOAD_SPEED = 1024         # ...and 1 MB/s up
MAX_DOWNLOAD_SPEED_1 = 0        # but the user 1 is not limited
MAX_UPLOAD_SPEED_2 = 256        # and the user 2 uploads at 256 KB/s
  • The limit is for all the connections of a user together: if the user opens four downloads they share it, they do not get four times as much. Two different users do not share anything.
  • Download and upload are limited apart: a download and an upload at the same time each have their own limit.
  • With no limit nothing changes: the download uses sendfile() at full speed. With a limit the file is sent in small pieces (about 50 ms of the limit), each after its turn.
  • A value that is not a whole number (fast, -5, 1.5) stops the server at start: a typo must not mean "no limit".
  • It limits the speed of the data, not what is stored: for a quota use the file system, see Disk quotas.

Users in a file of their own

USERS_FILE = /etc/uftp/users.cfg reads more users from a second file. It is off by default, and the users stay in uftpd.cfg as before if you do not use it.

  • The format is the same as in uftpd.cfg: USER_0, PASSWORD_0, HOME_0, USER_NAME_OWNER_0, PERMISSIONS_0 and the others. Each file numbers its own users from 0; the numbers need not be consecutive.
  • The users of the two files are added together. The same name twice (in the two files, or twice in the users file) stops the server with a message that names the user.
  • Why: the configuration can be shared or kept in a repository without passwords, and the two files can have different permissions: the passwords (better as hashes) stay in a file that only the owner, and the group of the server, can read. A users file that anybody can read is said in the log.
  • Use an absolute path. A file that does not exist stops the server.

To make the file from the users you already have in uftpd.cfg:

./uFTP --split-users                    # makes uftpd-users.cfg next to uftpd.cfg; uftpd.cfg is not changed
./uFTP --split-users --apply            # the same, and rewrites uftpd.cfg: it is saved as uftpd.cfg.bak first
./uFTP --split-users --config /etc/uftp/uftpd.cfg --users-file /etc/uftp/users.cfg --apply

The command copies the lines USER_n, PASSWORD_n, HOME_n, USER_NAME_OWNER_n, GROUP_NAME_OWNER_n, MAX_CONNECTION_PER_ACCOUNT_n, PERMISSIONS_n and READ_ONLY_n as they are (BLOCK_USER_n stays in uftpd.cfg: it is a list of names, not a user). The blocks of two users are separated by a blank line. The users file and the backup, which hold the passwords, are readable only by the owner, and by the group of uftpd.cfg if it could read that file (0600 or 0640). It never overwrites a users file or a backup that exists. Without --apply it tells you what to change by hand. After --apply, SIGHUP (or a restart) reads the users again.

Hashed passwords

PASSWORD_n can be a hash instead of the password, so a copy of uftpd.cfg does not show the passwords. It needs a build with OpenSSL. uFTP uses PBKDF2-HMAC-SHA256.

./uFTP --hash-password

The program asks for the password twice and prints the line to write in the file:

PASSWORD_0 = $pbkdf2-sha256$600000$<salt>$<hash>

Plain passwords still work next to hashes. From a script, echo 'secret' | ./uFTP --hash-password reads the first line of the input.

The iterations

The number after pbkdf2-sha256$ is the number of iterations: how many times the calculation is repeated. A higher number makes every guess slower, for you and for anyone who steals the file and tries to guess the passwords. The default is 600,000. Choose another value with --iterations; it can be from 1 to 10,000,000:

./uFTP --hash-password --iterations 300000

The number is stored in the hash, so every user can have a different one, and you can change it at any time: make a new hash of the password with the new number and replace the line. The old hashes keep working.

Checking a stored hash takes the same calculation for a correct or an incorrect password. When at least one hashed password is configured, uFTP also runs a dummy check for an unknown name that reaches the local password check. Measured on a 12-core desktop CPU:

Iterations Time of one check
100,000 0.03 s
310,000 0.07 s
600,000 (default) 0.14 s
1,000,000 0.23 s
5,000,000 1.1 s

A small board is several times slower: measure it on the machine that runs the server, with time (echo test | ./uFTP --hash-password --iterations 600000).

Cost of password hash checks

Password hash checks run in a separate thread, so uFTP can continue serving other clients. Higher iteration counts still use more CPU and increase login time. When all worker slots are busy, uFTP replies 421 and the client can retry later.

The dummy check uses the highest configured iteration count. Each stored hash uses its own count, so login times can differ when the counts vary by account.

A long, random password matters more than the iterations: 600,000 iterations slow a guess down, they do not make 123456 safe.

Adding a user with uftpctl

uftpctl adduser asks for the name, the password (not shown), the home and the options, and writes the user for you, with the password already hashed. It writes to USERS_FILE when the configuration has one, otherwise to uftpd.cfg; --file PATH chooses the file. The home directory is not made, and the command says so when it does not exist. A name that is already in the configuration is refused.

uftpctl --config /etc/uftp/uftpd.cfg adduser
uftpctl --config /etc/uftp/uftpd.cfg passwd alice
uftpctl --config /etc/uftp/uftpd.cfg --iterations 200000 adduser
uftpctl --config /etc/uftp/uftpd.cfg --file /etc/uftp/users.cfg adduser

--iterations N chooses how many times the password is hashed (1 to 10,000,000, the default is 600,000; see The iterations). passwd NAME changes only the PASSWORD_n of that user. The file keeps its mode and its owner; the text before the change is saved as <file>.bak, then .bak.1 and so on, and the new file is written aside and renamed, so a stopped command does not leave it half written. The password is never an argument of the command (it would show in ps and in the shell history). A build of uftpctl without OpenSSL can not make the hash and refuses adduser and passwd. These two commands change the file and do not use CONTROL_SOCKET. The server reads the new file at the next start or on SIGHUP (systemctl reload, uftpctl reload); uFTP --check tells if anything is wrong.

Reading the users again

SIGHUP (systemctl reload uftp, kill -HUP, uftpctl reload) reads the certificate and the users again: the users of the configuration file and of USERS_FILE. A user that was added can log in, one that was removed can not, a new password and new permissions work: no restart, and the connections that are open go on with the settings they had. A file that is not valid (a missing HOME_n, a name twice, a file that is gone) leaves the users in use, and the log says why. Nothing else of the configuration is read (ports, folders, limits of the server, BLOCK_USER_n): a restart is needed for those.

System users (PAM)

ENABLE_PAM_AUTH = true logs in the users of the system (/etc/passwd, /etc/shadow) instead of the list in the file. It needs a build with PAM (see Installation). Expired accounts are refused.

Option Default Meaning
PAM_SERVICE_NAME sudo The PAM service that checks the password (/etc/pam.d/<name>).

By default uFTP uses the PAM service named sudo, so the policy of /etc/pam.d/sudo decides who can log in to the FTP server, which has nothing to do with FTP. Better a service of its own: copy contrib/pam/uftp to /etc/pam.d/uftp and set PAM_SERVICE_NAME = uftp. Choose there who can log in (for example only the members of a group). The name is a word (letters, digits, -, _ and .); another name stops the server at start. The default stays sudo so that installations that exist keep working.

With PAM every system user allowed by the PAM policy can log in: use accounts made for FTP (shell /usr/sbin/nologin), restrict access to a group (the sample policy shows pam_succeed_if.so user ingroup ftpusers), keep BLOCK_USER_0 = root, and use FORCE_TLS, since these are system passwords. The Debian and Ubuntu package installs /etc/pam.d/uftpserver, which includes the system's common-auth and common-account policies. On shadow-based systems the standard pam_unix module checks the account password using /etc/shadow and checks account status; see pam_unix(8). For package setup and the required systemd drop-in, see Installation.

Full sample

The sample file with comments is in the source: uftpd.cfg.