Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Could you provide ls -la in /var/www and /var/www/$USER ? –  sibidiba Nov 26 at 9:46

3 Answers 3

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
share|improve this answer
    
This doesn't look like it's set up for virtual users. Is it? –  Mr. Squig Nov 21 '12 at 15:53

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

share|improve this answer
1  
Being that zac is a virtual user it's unlikely that the directory is owned by zac since it's not an actual user on the server. –  Jakobud Oct 3 '13 at 15:49
    
The directory should be owned & readable by virtual. Due to chroot, it is required that it is not writable. You need to create a read-writable subdirectory within (owned by virtual) to be able to upload therein. –  sibidiba Nov 26 at 10:06

Try this for virtual users to enable write access:

virtual_use_local_privs=YES
share|improve this answer
    
If you carefully read the question again, you will notice that this line is already part of the OPs config file. –  Sven Nov 25 at 10:18
    
You are right... –  sibidiba Nov 26 at 9:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.