I’ve done this before with the help of a very good blog entry. But when I tried to do the same thing today I can’t find that page. So I decide to write this down, in case I’ll need it later.
The most problem of setting up Vsftpd with file based virtual user on FreeBSD is that we don’t have pam_userdb. So we’ll use /usr/ports/security/pam_pwdfile instead.
So after installing the vsftpd and pam_pwdfile ports, do the following:
(1) in /etc/pam.d, make a file named “vsftpd” and put the following lines in it:
(2) make a password file with the apache htpasswd utility:
(3) make a local user with “nologin” as the shell and disable password login. I use “vsftp” for this.
(4) in /usr/local/etc/vsftpd.conf, disable anonymous access and enable local user access, and then add the following:
Note the value of “guest_usrname” is the local user name you made in step (3)
(5) make a directory /usr/local/etc/vsftpd, and write user specific configurations in a file named after the user’s login name. For example, someone with full write access will have something like this:
(6) It should be OK now, add vsftpd_enable=”YES” into /etc/rc.conf as usual, and restart vsftpd to see if everything works fine.