ELS Howto: FTP Server


Synopsis

This document describes how to set up a File Transfer Protocol (FTP) server on an Elemental Linux Server (ELS) machine using ProFTPD.


Prerequisites

You will need to have the ELS 'Extra Applications' CD-ROM mounted on /media/cdrom.


Installation

The following instructions describe how to install ProFTPD using the ELS CD-ROM.

  1. Extract the ProFTPD package into the root of the server's directory hierarchy.
  2. Create symbolic links for the ProFTPD package's binaries in the /opt/bin and /opt/sbin directories.

Example

The example below shows how you would install version 1.3.4a of ProFTPD from the ELS CD-ROM.

cd /
tar -zxf /mount/cdrom/extra/proftpd-1.3.4a.i586.tar.gz

cd /opt/bin
ln -s ../proftpd-1.3.4a/bin/* .
cd /opt/sbin
ln -s ../proftpd-1.3.4a/sbin/* .

Configuration

After installing ProFTPD, follow the steps below to configure ProFTPD as an FTP server with the option of anonymous logins.

  1. Create the directory /etc/opt/proftpd.
  2. Copy the sample configuration file from the ProFTPD package's etc directory into the newly created directory.
  3. Configure firewall rules to allow incoming FTP traffic.
  4. Set proftpd to start automatically at boot-up.

Example

The example below shows how to create the ProFTPD configuration directory and copy the proftpd.conf file. It also shows the changes to /etc/firewall as well as the commands used to set proftpd for automatic start-up.

mkdir /etc/opt/proftpd

cp /opt/proftpd-1.3.4a/etc/proftpd.conf /etc/opt/proftpd/proftpd.conf

vi /etc/firewall

-A INPUT -p tcp -s 192.168.1.0/24 --dport 21 -j ACCEPT

/etc/init.d/network restart

chmod +x /etc/init.d/proftpd

Note

The IP address range shown above is for demonstration purposes only and should be changed to match your network configuration.


Testing

You can test your setup by downloading some files via FTP.

  1. Manually start proftpd.
  2. Start an FTP connection to the local host.
  3. Log in as a non-root user.
  4. Download a file and verify that the file has been retrieved successfully.

Here is an example of a successful test.

login: root
password:

# /etc/init.d/proftpd start
FTP server is starting.

# ftp 127.0.0.1
Connected to 127.0.0.1.
220 ProFTPD 1.3.4a Server (ProFTPD Default Installation) [127.0.0.1]
Name (127.0.0.1:root): joe
331 Password required for joe
Password:
230 User joe logged in
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd /etc
250 CWD command successful
ftp> get passwd
local: passwd remote: passwd
227 Entering Passive Mode (127,0,0,1,145,254).
150 Opening BINARY mode data connection for passwd (214 bytes)
226 Transfer complete
214 bytes received in 0.000192 secs (1.1e+03 Kbytes/sec)
ftp> quit
221 Goodbye.

# cat passwd

root::0:0:Super User:/root:/usr/bin/bash
bin:x:1:1:Legacy UID:/bin:/bin/false
daemon:x:2:2:Legacy UID:/sbin:/bin/false
nobody:x:99:98:Nobody:/tmp:/bin/false
joe:501:500:/home/joe/usr/bin/bash

If your test was not successful, here are some troubleshooting tips.

  1. Check the firewall rules with iptables -L -n and verify that TCP traffic is allowed in on port 21 for any hosts on your network.
  2. Use the command netstat -tln to verify that proftpd is listening on port 21.

Additional Information

The ProFTPD website has a collection of documentation that may be helpful.