install
  1. Vsftpd Config

    . Installation of VSFTPD

    For Red Hat, CentOS and Fedora, you may install VSFTPD by the command

    # yum install vsftpd

    For Debian and Ubuntu,

    # apt-get install vsftpd

    2. Virtual users and authentication

    We are going to use pam_userdb to authenticate the virtual users. This needs a username / password file in `db’ format – a common database format. We need `db_load’ program. For CentOS, Fedora, you may install the package `db4-utils’:

    # yum install db4-utils

    For Ubuntu,

    # apt-get install db4.2-util

    To create a `db’ format file, first create a plain text file `virtual-users.txt’ with the usernames and passwords on alternating lines:

    mary
    123456
    jack
    654321

    Then execute the following command to create the actual database:

    # db_load -T -t hash -f virtual-users.txt /etc/vsftpd/virtual-users.db

    On Ubuntu

    # db4.2_load -T -t hash -f virtual-users.txt /etc/vsftpd/virtual-users.db

    Now, create a PAM file /etc/pam.d/vsftpd-virtual which uses your database:

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

    3. Configuration of VSFTPD

    Create a configuration file /etc/vsftpd/vsftpd-virtual.conf

    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=/ftpfolder/$USER
    force_dot_files=YES
    chroot_local_user=YES
    hide_ids=YES
    listen=YES
    listen_port=21
    pasv_min_port=62222
    pasv_max_port=63333
    connect_from_port_20=YES
    local_umask=022
    tcp_wrappers=YES
    accept_timeout=180

    4. Creation of home directories

    Create each user’s home directory in /ftpfolder, and change the owner of the directory to the user `ftp’:

    # mkdir /ftpfolder/mary
    # chown ftp:ftp /ftpfolder/mary