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¶
-
Use a port above 1024. Linux does not let a normal user listen on the standard port 21.
FTP_PORT = 2000 -
Keep the configuration in the directory you start it from. The server reads
./uftpd.cfgfirst and/etc/uftpd.cfgafter, so you do not need/etc. -
Turn off what needs root.
SINGLE_INSTANCE = false DAEMON_MODE = falseWithout 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.
-
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
plutoand the group ispluto:USER_0 = plutoftp PASSWORD_0 = a-long-secret HOME_0 = /home/pluto/ USER_NAME_OWNER_0 = pluto GROUP_NAME_OWNER_0 = pluto -
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
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.