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

Ideally I'd like something like proftpds ability to do this

DefaultRoot /var/www/whatever/userone/ user1
DefaultRoot /home/directory/whatever/ user2

It's important that this be for virtual users.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Yes, it's possible, see my post here:

vsftpd - local_root=/var/www/sites/$USER doesn't get interpreted?

You need to use the per-user config files in order to specify a unique chroot location for them. In your case the per-user config "local_root" will be varying values outside of /var/www/sites/ as required.

share|improve this answer

This can be done very easily with PAM.

If your disto doesn't come with PAM, then you'll need to grab a copy, as vsftpd uses PAM for authentication of virtual users.

There is a debian package for pam_pwdfile already available, alternatively, download and compile it, if your copy of linux doesn't come with it already:

apt-get install libpam-pwdfile

First, create a password file for the first user:

htpasswd -c /etc/vsftpd/passwd user1

And then:

htpasswd /etc/vsftpd/passwd user2

Next you need to edit the vsftpd configuration file /etc/vsftpd.conf

listen=YES
anonymous_enable=NO
local_enable=YES
virtual_use_local_privs=YES
write_enable=YES
connect_from_port_20=YES
secure_chroot_dir=/var/run/vsftpd
pam_service_name=vsftpd
guest_enable=YES
user_sub_token=$USER
local_root=/var/www/sites/$USER
chroot_local_user=YES
hide_ids=YES

Finally you need to configure PAM to use the password file, so edit /etc/pam.d/vsftpd

# Customized login using htpasswd file
auth    required pam_pwdfile.so pwdfile /etc/vsftpd/passwd
account required pam_permit.so

Don't forget to restart vsftpd, and that's pretty much it!

share|improve this answer
    
Cheers, but I know to setup virtual users and structured chroots. I was wondering if each user could have a complete different chroot, something outside /var/www/sites/ in your example. –  RecQuery Jan 26 '11 at 8:36

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.