Tuesday, November 14, 2006

Sharing is Caring

I am so excited right now, I finally got my ftp back up and running. I run vsftpd with virtual users and this will be a guide to setting it up.


  1. Install vsftpd. On foresight just run:

    sudo conary update vsftpd

  2. Create the file with username and password (/etc/vsftpd/logins.txt). The file is an alternating list of username and passwords:

    tom
    foo

  3. Add the database file (This requires Berkeley DB program installed):

    db_load -T -t hash -f /etc/vsftpd/logins.txt /etc/vsftpd/vsftpd_login.db

  4. Fix database permissions:

    chmod 600 /etc/vsftpd/vsftpd_login.db

  5. Setup pam, Change /etc/pam.d/ftp to only contain the following lines:

    auth required /lib/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login crypt=hash

    account required /lib/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login crypt=hash


  6. Create virtual user:

    useradd -d /home/ftp virtual

  7. Create /etc/vsftpd/vsftpd.conf containing the following lines:

    anonymous_enable=NO
    local_enable=YES
    write_enable=NO
    anon_upload_enable=NO
    anon_mkdir_write_enable=NO
    anon_other_write_enable=NO
    chroot_local_user=YES
    guest_enable=YES
    guest_username=virtual
    listen=YES
    listen_port=21

  8. Restart vsftpd:

    sudo /etc/init.d/vsftpd restart

Anytime you add a user to /etc/vsftpd/logins.txt you have to add the database again by running:
db_load -T -t hash -f /etc/vsftpd/logins.txt /etc/vsftpd/vsftpd_login.db

If you would like an account just let me know.

No comments: