Setting ProFTPD on Fedora and CentOS

I have not setup FTP server for a long time. Most of the time when I want to transfer files, I usually use SCP of SFTP. But this blog entry is a simple instruction set how to setup and configure basic FTP service. I'm using the ProFTPD on Fedora 12. Most of the material has been taken and modified from Linux Format Magazine

First thing first. What is ProFTP?

 ProFTPD is a stable and full-featured FTP Server. It can be run as a standalone server or from xinetd. It supports anonymous, authenticated logins, authenticated with LDAP directories or even sql databases.

 Installation of ProFTP Server
yum install proftpd
chkconfig --levels 235 ptoftpd on

To enable anonymous logins, edit the /etc/sysconfig/proftpd file
# vim /etc/sysconfig/proftpd

Inside the /etc/sysconfig/proftpd file
PROFTPD_OPTIONS="-DANONYMOUS_FTP"

# service proftpd restart

The default home directory of the anonymous logins is /var/ftp/
The default directory to place content for anymous users to put is at /var/ftp/pub
The default directory for anonymous users to upload to /var/ftp/upload


2. Virtual Hosting
Unfortunately, FTP require different IP Address for each site even though it is supposed to be virtual hosting. Unlike HTTP protocol which includes a host header field.

 Assuming you have several IP Addresses which you can use uniquely for your Virtual Hosting, you still need to set up IP Alias on the network card and a "VirtualHost" section in the proftpd.conf

Create a Network Card Alias
Step 2a - Create a network card alias for the network card
# touch /etc/sysconfig/network-scripts/ifcfg-eth0:N 
(where N is the alias number)

Step 2b: Inside ifcfg-eth0:N
DEVICE=eth0:1
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.2
HARDWARE=xx:xx:xx:xx:xx:xx

Step 2c: Restart Network Service
# service network restart


Step 3: Configure the VirtualHost inside the /etc/proftpd.conf
The script is rather long, you can get a sample from http://www.proftpd.org/docs/configs/virtual_authuserfile.conf

Bascially, you can change the Default Chdir to a new path ie /var/ftp/site2/pub. You can also change the message /var/ftp/site2/welcome.msg


Further Notes:
  1. List of Directives for ProFTPD configuration files 
  2. Active FTP vs. Passive FTP, a Definitive Explanation
  3. Virtual Hosting With Proftpd And MySQL (Incl. Quota)
  4. PROFTPD virtual user – quick howto