Installation¶
On Debian, Ubuntu, Rocky Linux and EL, the recommended method is the signed APT or DNF repository (see Packages and repositories). The packages are also on the download page; install one with the commands below. If a matching package is not available, or you need a custom build or another POSIX system, use the source instructions on this page.
Requirements¶
| What | Needed for | Debian / Ubuntu package |
|---|---|---|
git, gcc (4.9 or later, or clang), make |
building | git gcc make |
| OpenSSL development files | TLS (FTPS), hashed passwords | libssl-dev |
| PAM development files | logins with system users (optional) | libpam0g-dev |
sudo apt-get install git gcc make libssl-dev
Build¶
git clone https://github.com/kingk85/uFTP.git
cd uFTP
make
The program is build/uFTP. A plain make builds without TLS. Choose the features with options on the make line:
| Feature | Option |
|---|---|
| TLS (FTPS) and hashed passwords | ENABLE_OPENSSL_SUPPORT="-D OPENSSL_ENABLED" LIBS="-lpthread -lssl -lcrypto" |
| Logins with system users (PAM) | ENABLE_PAM_SUPPORT="-D PAM_SUPPORT_ENABLED" PAM_AUTH_LIB=-lpam |
| No IPv6 (old systems) | ENABLE_IPV6_SUPPORT= |
Always use poll() instead of epoll |
CFLAGSTEMP="-c -Wall -I. -D UFTP_USE_POLL" |
For example, TLS and PAM together:
make ENABLE_OPENSSL_SUPPORT="-D OPENSSL_ENABLED" \
ENABLE_PAM_SUPPORT="-D PAM_SUPPORT_ENABLED" PAM_AUTH_LIB=-lpam \
LIBS="-lpthread -lssl -lcrypto"
You can also edit the options in the Makefile: uncomment the lines that the comments describe. Large file support (files over 2 GB) is already on.
Note
On Linux the server waits for its connections with epoll; on other systems it uses poll().
Install¶
Use these commands for a first installation.
sudo cp build/uFTP /sbin/uFTP
sudo mkdir -p /etc/uftp
sudo install -o root -g root -m 0600 uftpd.cfg /etc/uftp/uftpd.cfg
sudo install -d -o root -g root -m 0750 /srv/ftp/alice
Edit the configuration with sudoedit /etc/uftp/uftpd.cfg. Enable the three account lines at the end of the file and set the password. With OpenSSL, generate a hash with /sbin/uFTP --hash-password and configure the certificate and key before starting. Configuration ยท TLS and certificates
uFTP reads ./uftpd.cfg before falling back to /etc/uftp/uftpd.cfg. Start in /etc/uftp to use the file you just edited.
If your previous installation used /etc/uftpd.cfg, merge the settings and accounts you need into /etc/uftp/uftpd.cfg before starting the new server.
(cd /etc/uftp && sudo /sbin/uFTP --check /etc/uftp/uftpd.cfg && sudo /sbin/uFTP)
Start at boot (systemd)¶
uFTP can run in the background by itself (DAEMON_MODE, with a supervisor that restarts it, RESPAWN_PROCESS). With systemd it is
cleaner to let systemd do both: set DAEMON_MODE = false and RESPAWN_PROCESS = false in uftpd.cfg, and create
/etc/systemd/system/uftp.service:
[Unit]
Description=uFTP server
After=network.target
[Service]
Type=simple
WorkingDirectory=/etc/uftp
ExecStart=/sbin/uFTP
Restart=on-failure
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now uftp
sudo systemctl status uftp
To run the service as an unprivileged user, with the disk read-only and only port 21 allowed, see Run as a service (systemd).
The logs are written to LOG_FOLDER (one file a day), see Configuration.
Upgrade¶
Read the release notes first: some defaults change between versions. Keep your uftpd.cfg; new options have defaults and are
described in the sample file of the new version.
From the Debian/Ubuntu package or repository:
sudo apt update
sudo apt install --only-upgrade uftpserver
If the version is the same (a test server with a rebuilt package), use sudo apt install --reinstall uftpserver. The
configuration /etc/uftp/uftpd.cfg is a conffile: it stays, and so does the systemd drop-in.
From the RPM repository:
sudo dnf upgrade uftpserver
If the version is the same, sudo dnf reinstall uftpserver.
Then check and restart:
uFTP --check
sudo systemctl restart uftpserver # or uftp for the source unit
From the source: build the new version, stop the server, replace /sbin/uFTP and start it again.
Other platforms¶
Debian and Ubuntu package¶
The package is called uftpserver (Debian has another program, a multicast file transfer, in a package uftp). Download the .deb for your distribution and architecture from the download page. There are packages for amd64, arm64 (Debian 12/13, also Raspberry Pi OS 64-bit) and armhf (Raspberry Pi OS 32-bit; it needs ARMv7, so a Raspberry Pi 2 or later, not a Pi 1 or Zero). For example, on Debian 12 x86-64:
sudo apt install ./uftpserver_4.4.0-1~debian12_amd64.deb
The asset name identifies the distribution and architecture; use the matching file rather than the example above. The signed APT repository is the recommended way (see Packages and repositories).
It makes the user uftp, /etc/uftp/uftpd.cfg without users and a self-signed certificate if there is none, and starts nothing. Add a virtual FTP user before starting the service.
The package configuration lists the settings by section. Optional settings are commented out with notes; remove the leading # and set a value to enable one.
Add a test user and connect¶
Create a home directory that the service user can access, generate a password hash, and edit the package configuration:
sudo install -d -o uftp -g uftp -m 0750 /srv/ftp/testftp
sudo /usr/sbin/uftpctl --config /etc/uftp/uftpd.cfg adduser
uftpctl adduser asks for the name, the password (not shown), the home and the options, and writes the user with a PBKDF2 hash;
see Users. By hand, uFTP --hash-password makes the hash and sudoedit /etc/uftp/uftpd.cfg adds the lines.
USER_0 = testftp
PASSWORD_0 = <generated password hash>
HOME_0 = /srv/ftp/testftp/
Check the configuration and start the service:
sudo /usr/sbin/uFTP --check /etc/uftp/uftpd.cfg
sudo systemctl enable --now uftpserver
sudo /usr/sbin/uftpctl --config /etc/uftp/uftpd.cfg status
Connect with an FTP client using explicit FTPS, port 21, and the testftp credentials. On the same machine, use 127.0.0.1 as the host. The first-install certificate is self-signed, so the client will ask you to trust it. For remote connections, allow the passive port range through the firewall.
The package has TLS and PAM. PAM is off by default. To authenticate system accounts with their system passwords:
- Set
ENABLE_PAM_AUTH = trueandFORCE_TLS = truein/etc/uftp/uftpd.cfg. The package setsPAM_SERVICE_NAME = uftpserverand installs/etc/pam.d/uftpserverfor you. - That PAM policy includes
common-authandcommon-account; on shadow-based systems,pam_unixchecks the password stored in/etc/shadowand the account status. Restrict the policy to an FTP-only group if you do not want every account allowed by the system policy to log in; see System users (PAM). - For local system accounts, install the package's restricted systemd drop-in. The default service user
uftpcannot authenticate local accounts with this PAM policy. Read the drop-in before enabling it: it runs uFTP as root with a limited capability set and allows access to users' home directories. It is also needed forUSER_NAME_OWNER_nmappings that assign uploaded files to another owner. See Run as a service (systemd):
sudo install -D -m 644 /usr/share/doc/uftpserver/examples/systemd/pam-system-users.conf /etc/systemd/system/uftpserver.service.d/pam-system-users.conf
sudo systemctl daemon-reload && sudo systemctl restart uftpserver
The configuration of the package blocks root (BLOCK_USER_0 = root). Read the drop-in before: the server then runs as root (with a few privileges only) and can read and write /home. Remove the file to go back. Users from LDAP or Active Directory
through sssd may not need it: try first without.
Or build it: packaging/debian/build-deb.sh. man uFTP, man uftpctl and man uftpd.cfg are in the package. apt remove stops the service and keeps the configuration,
apt purge removes it too; the files of the users, the certificates and the user uftp stay.
Rocky Linux and EL package¶
The RPM is called uftpserver. Download it for your release and architecture from the download page:
el9 or el10, and x86_64 or aarch64. For example, on Rocky Linux 9 x86-64:
sudo dnf install ./uftpserver-4.4.0-1.el9.x86_64.rpm
The signed DNF repository is the recommended way (see Packages and repositories). The package makes the user uftp, /etc/uftp/uftpd.cfg (root:uftp, 0640) without users,
and a self-signed certificate in /etc/uftp/tls if there is none; it starts nothing. Add a virtual FTP user and start the service:
sudo /usr/sbin/uftpctl --config /etc/uftp/uftpd.cfg adduser
sudo systemctl enable --now uftpserver
The service is uftpserver.service; systemctl reload uftpserver reads the certificate and the users again. The package has no
SELinux policy: if SELinux is enforcing and the service is refused, look at the audit log and add a local policy. Removing the
package leaves the users' files (/srv/ftp) and the certificate.
Packages and repositories¶
The packages and the signed APT/DNF repositories are on the Packages and repositories page: the block for each distribution, the key fingerprint, the updates, the removal and the troubleshooting.