Title: Implement an FTP Server
Course: CIS 208: Linux/UNIX III: Intermediate System Administration, Networking, and Security ~ For IGNITE Review > Section: Learning Modules

Implement an FTP Server

- Install vsftpd and db4-utils on the selected server.
- Create the directory /var/vsftp and optionally mount a separate partition to this directory.
- Create a directory for each account, for example:

mkdir /var/vsftp/{project1,project2}

- Create the file /etc/vsftpd/virt-users and include the FTP usernames and passwords which will be used.  For example:

project1
p1password
project2
p2password

- Next create a db file containing these credentials:

db_load -T -t hash -f /etc/vsftpd/virt-users /etc/vsftpd/virt-users.db

- The following two lines need to be included in /etc/pam.d/vsftpd-virtual.conf.

auth required pam_userdb.so db=/etc/vsftpd/virt-users
account required pam_userdb.so db=/etc/vsftpd/virt-users

- Paste the following lines to /etc/vsftpd/vsftpd-virtual.

anonymous_enable=NO local_enable=YES
guest_enable=YES
virtual_use_local_privs=YES
write_enable=YES
pam_service_name=vsftpd-virtual
user_sub_token=$USER
local_root=/var/vsftp/$USER
chroot_local_user=YES
hide_ids=YES
listen=YES
pasv_max_port=63333
connect_from_port_20=YES
local_unmask=022

- If ssl encryption is to be used, add the following to /etc/vsftpd/vsftpd-virtual.  Note that the .pem and .key files must exist.  See the command below to create the files.

rsa_cert_file=/etc/vsftpd/vsftpd.pem
rsa_private_key_file=/etc/vsftpd/vsftpd.key
ssl_enable=YES
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
ssl_sslv2=YES
pasv_min_port=52000
pasv_max_port=55000

- This command will create the ssl files for vsftpd.

openssl req -x509 -nodes -newkey rsa:2048 -keyout/etc/vsftpd/vsftpd/key\
-out /etc/vsftpd/vsftpd.pem -days 1095

- Restart the vsftpd service and verify that you can make a connection using ssl.