I want to setup a
www-data user for vsftpd and set its root dir to
How can I do this?
Assuming you want a real system user to access ftp, you will have to set the option local_enable=Yes. But if you do that, all your users will automatically be able to log in via FTP. Therefore it might be a good idea to setup a whitelist of FTP users by setting userlist_enable=Yes, userlist_deny=No and specifying 'userlist_file'. If you wish to lock users in their home directories, you can set chroot_local_user=Yes
minimal sample /etc/vsftpd.conf:
Vsftpd also supports virtual users via PAM integration. Set guest_enable=Yes in /etc/vsftpd.conf. This has the effect of mapping every non-anonymous successful login to the local username specified in 'guest_username'. Then, use PAM and (e.g.) its pam_userdb module to provide authentication against an external (i.e. non-/etc/passwd) repository of users. I've never personally used this configuration, but there are examples of virtual users setups in the example directory.
First log in as root: sudo -i.
That user should then be able to log in.