Table of Contents

Ubuntu - FTP - Install vsftpd using text file for virtual users

Install required packages

sudo apt install vsftpd libpam-pwdfile

Configure vsftpd

Edit these variables in the config file and leave everything else with the default value.

/etc/vsftpd.conf
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
nopriv_user=vsftpd
virtual_use_local_privs=YES
guest_enable=YES
user_sub_token=$USER
local_root=/var/www/$USER
chroot_local_user=YES
hide_ids=YES
guest_username=vsftpd

NOTE: Set the local_root to the parent directory where the user’s home directories are located.


Configure PAM

Configure PAM to check the passwd file for users.

/etc/pam.d/vsftpd
auth    required pam_pwdfile.so pwdfile /etc/ftpd.passwd
account required pam_permit.so

Make sure you remove everything else from the file.


Create the passwd file containing the users

htpasswd -cd /etc/ftpd.passwd user1

You can later add additional users to the file like this:

htpasswd -d /etc/ftpd.passwd user2

Create a local user account to authenticate virtual users

Create a local user that’s used by the virtual users to authenticate.

useradd --home /home/vsftpd --gid nogroup -m --shell /bin/false vsftpd

Restart vsftpd

/etc/init.d/vsftpd restart

Create home directory

Create user’s home directory since vsftpd doesn’t do it automatically.

mkdir /var/www/user1
chown vsftpd:nogroup /var/www/user1
chmod a-w /var/www/user1