Skip to content

Run without root

uFTP can run as a normal user. This is useful on embedded devices that have no root account, or to give the server fewer privileges.

Steps

  1. Use a port above 1024. Linux does not let a normal user listen on the standard port 21.

    FTP_PORT = 2000
    
  2. Keep the configuration in the directory you start it from. The server reads ./uftpd.cfg first and /etc/uftp/uftpd.cfg after, so you do not need /etc.

  3. Turn off what needs root.

    SINGLE_INSTANCE = false
    DAEMON_MODE = false
    

    Without these two options the server avoids the system calls that normal users cannot make. Run it from a terminal, a script or a service of your user.

  4. Make the users match your user. A normal user cannot change the owner of a file, so set the owner of the new files to the user that runs the server. If your user is pluto and the group is pluto:

    USER_0 = plutoftp
    PASSWORD_0 = a-long-secret
    HOME_0 = /home/pluto/
    USER_NAME_OWNER_0 = pluto
    GROUP_NAME_OWNER_0 = pluto
    
  5. Put the logs in a folder you can write, with a final /:

    LOG_FOLDER = /home/pluto/uFTP/logs/
    

Then start it as your user:

./uFTP

Note

If you configure an owner that is not the user that runs the server, the files cannot be given to that owner (changing an owner needs root). The log says so at startup and when it happens; the uploads still work.

Note

ENABLE_PAM_AUTH (logging in system users) and the private key of the certificate need to be readable by your user. For FTPS, keep the key in a folder only your user can read.

Tip

To run it as a service, or in a container, with the privileges removed by the system and not by hand, see Run as a service (systemd) and Run in Docker.