I run a small, non-anonymous FTP server for myself and some friends, primarily to use as a server for the excellent Foxmarks Bookmark Synchronizer. It's simple and gets the job done and I'm not particularly concerned with security (obviously).
The first step (in Gentoo, anyways) is to emerge pam_userdb and vsftpd. BerkDB (db) will be used to store the usernames and passwords of the accounts, generated from a flat text file that contains alternating lines of username and password. The configuration file will allow these users to write to the ftp server - this configuration does not include per-user chroots, so keep in mind anyone with an account can access any of the files on the server.
We'll start with setting up the user database:
Now we have some accounts, we'll setup PAM. Gentoo comes with an /etc/pam.d/ftp file, but we'll remove it and write our own as suggested from vsftpd's README: vsftpd.pam.
The only addition we'll make is the hash=crypt:
I saved these lines to /etc/pam.d/vsftpd and symlinked that file to /etc/pam.d/ftp, moving the original ftp file out of the way. Now that the authentication aspect is done, we'll create the configuration file, once again using the vsftpd EXAMPLE file: as a base. Below is the configuration file I use, with comments explaining why:
The vsftpd daemon runs as root, but uses the ftp users' home directory for the ftp root (which on Gentoo defaults to /home/ftp). On Solaris and UNIX systems, this is typically /var/ftp.
In either case, you'll need to chmod 775 the directory. Subsequent files and directories will be 775 as well. Note that if you do not have the world bits set to read and execute vsftpd will deny you read access to the directory. If the rwx group bits aren't set, write access will be denied. Be sure to change anon_umask=022 to anon_umask=002 or else you wont be able to modify files/directories you create.
I've taken some of these steps from the Gentoo Wiki on vsftpd HOWTO_vsftpd, which, in my humble opinion, is terribly written.
More useful is the man page for the configuration file of vsftpd.conf
Post new comment