VSFTPD does not allow upload with virtual users

I am attempting to setup VSFTPD with virtual users on a server running Ubuntu 12.04. I have configured the server to allow for virtual users to login, but I am having trouble getting it to allow uploads. My vsftpd.conf is as follows:

listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=YES
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES

chroot_local_user=YES
virtual_use_local_privs=YES
guest_enable=YES
guest_username=virtual
user_sub_token=$USER
local_root=/var/www/$USER
hide_ids=YES

secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/private/vsftpd.pem

/etc/pam.d/vsftpd contains:

auth required pam_pwdfile.so pwdfile /etc/vsftpd.passwd crypt=hash
account required pam_permit.so crypt=hash

I have two virtual users set up, one of which has the same name as a local user. They each have a directory in /var/www/ owned by 'virtual'. As I understand it, when a virtual user logs in this way they will appear to the system as the user virtual. Using this configuration user can log on, but cannot upload files. The error given in /var/log/vsftpd.log is:

Tue Nov 20 19:49:00 2012 [pid 2] CONNECT: Client "96.233.116.53"
Tue Nov 20 19:49:07 2012 [pid 1] [zac] OK LOGIN: Client "96.233.116.53"
Tue Nov 20 19:49:11 2012 [pid 2] CONNECT: Client "96.233.116.53"
Tue Nov 20 19:49:11 2012 [pid 1] [zac] OK LOGIN: Client "96.233.116.53"
Tue Nov 20 19:49:11 2012 [pid 3] [zac] FAIL CHMOD: Client "96.233.116.53", "/test.ppm 644"

I have tried changing the permissions of these directories in all sorts of ways, but nothing seem to work. I have a feeling that it is something simple related to permissions. Any ideas?


The problem may caused by directory permission, I've vsftpd that worked for me as below:

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
chown_uploads=YES
xferlog_file=/var/log/vsftpd.log
xferlog_std_format=YES
ftpd_banner=Welcome to blah FTP service.
ls_recurse_enable=NO
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

Does the directory exist?

 /var/www/zac

and does this directory belong to zac?

try:

 mkdir -p /var/www/zac; chown zac /var/www/zac; chmod 600 /var/www/zac;

and upload the file again


VSFTP does not allow uploads for virtual users you need to create local user or you can use single user mapped to all virtual users in that case you cannot control user wise permission check this link - https://gist.github.com/stas/315765