This guide is trying to help new linux users to setup ProFTPD service in a VPS server running Ubuntu server. The instructions here are my expereience and may not be best-practice for any production use. The configuration includes two users who have different access rights to same directory.
Preparation:
Add a dummy shell to the system (so that the ftp users cannot login to the system via ssh)
# echo "/bin/false" >> /etc/shells
Create two directories for upload / download purposes respectively.
# mkdir -p /home/ftphome/download /home/ftphome/upload
Modify the directories to approiate access rights.
# chmod 775 /home/ftphome/download
# chmod 775 /home/ftphome/upload
Create users for ftp access:
# useradd userftp -d /home/ftphome -p password -s /bin/false
# useradd adminftp -d /home/ftphome -p password -s /bin/false
Reset the password again (enter the below command one by one and input the password again when prompted):
# passwd userftp
# passwd adminftp
Add the adminftp user to the same group as userftp. This step allows adminftp to modify files uploaded by userftp.
#usermod -a -G userftp adminftp
Modify owner of the directories.
# chown userftp:userftp/home/ftphome/download /home/ftphome/upload
Installation:
# apt-get update
# apt-get install proftpd
You will be asked if ProFTPD should run in inetd or standalone mode. While inetd in general use less system resources but I would recommend to run in standalone mode for easier configuration and troubleshooting.
Configuration:
Edit the file using vi (vi is an advanced text editor which may not be as user friendly, you may use nano (apt-get install nano) instead) or other text editor and modify the settings:
# vi /etc/proftpd/proftpd.conf
...
ServerName "Debian" # Enter the name of this ftp server
...
DefaultRoot ~ # uncomment this line to enable default root option
...
PassivePorts 60000 61000 # uncomment and modify this line to enable passive ftp support (range around 1000)
...
AllowOverwrite on # this line should exist by default
AllowRetrieveRestart on # add this line to allow download resume
AllowStoreRestart on # add this line to allow upload resume
You could continue the configuration file by adding per-directory settings at the bottom of this file but I prefer to create a separated file under /etc/proftpd/conf.d/
The configuration file allows access for two users. The user adminftp has administrative rights over the ftp server and should not be disclosed to third party (despite that ftp is insecure in nature). The user userftp will have limited rights to allow download / upload in certain ways:
- userftp can upload to the "upload" directory, but cannot view any documents inside (the file will be hidden after a refresh).
- userftp can view and download any files (including subdirectories) in the "download" directory.
- adminftp can view, upload and download in both "upload" and "download" directories
# vi /etc/proftpd/conf.d/ftp.conf
<Limit LOGIN>
AllowUser userftp
AllowUser adminftp
DenyAll
</Limit>
<Directory /home/ftphome>
Umask 022 022
AllowOverwrite off
<Limit DIRS>
AllowAll
</Limit>
</Directory>
<Directory /home/ftphome/download>
Umask 002 002
AllowOverwrite on
<Limit DIRS READ>
AllowAll
</Limit>
<Limit WRITE>
AllowUser adminftp
DenyAll
</Limit>
</Directory>
<Directory /home/ftphome/upload/*>
Umask 002 002
AllowOverwrite on
<Limit WRITE>
AllowAll
</Limit>
<Limit DIRS READ DELE>
AllowUser adminftp
DenyAll
</Limit>
</Directory>
<Directory /home/ftphome/upload>
Umask 002 002
AllowOverwrite on
<Limit DIRS WRITE>
AllowAll
</Limit>
<Limit READ DELE>
AllowUser adminftp
DenyAll
</Limit>
</Directory>
It is recommended to test the configuraion file using the below command. Note the number after -td is the debug level, more details will be displayed at high value (ranged from 0 to 10).
# proftpd -td2
Note: You may suffer from unexpected service down and may refer to
my previous post