Here’s a summary for vsftpd setup with virtual user and directory in Debian. It’s probably the same process on other Debian-based distros as well as Redhat-based distros. No need to define what’s vsftpd and what’s virtual users - let’s just proceed to the setup. :)
Install VSFTPD:
1
|
|
Choose what method to use for virtual user authentication. Let’s use pam passwd module (libpam-pwdfile), I guess this is the most common and easy to setup. You can also use libpam-mysql if you want to manage your ftp users via mysql database, like if you want integrate it with your application that’s using mysql as backend.
1
|
|
Next create your password file (example: /etc/vsftpd_users.conf) which contain the list of virtual users and password hash. You can use htpasswd that’s included in Apache or go to this website, htaccesstools.com to generate the list of users and passwords.
Once you have the list of users (example: demo1 and demo2), you have to create their virtual directory as well, let’s say I want to set ftp users home directory inside /home/ftpusers. This will be their home directory and they can’t see or navigate outside of their home dir. Make sure they’re writable as well.
1
|
|
Then update your vsftpd config (/etc/vsftpd.conf) and make sure you have the configs below enabled. Please take note that some of these configs might me enabled by default. Also, you might want to read the detailed description on /etc/vsftpd.conf file about the configurations that you want to enable/disable, example: allow local system users to connect to ftp, disable anonymous ftp access, welcome message, and so on.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Finally update the pam config (/etc/pam.d/vsftpd) with the lines below and remote or comment out existing lines in there.
1 2 |
|
Restart vsftpd and connect to your ftp server:
1
|
|