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

41,282

Solution 1

What you need to use is a combo of user_config_dir and local_root. In the main config file /etc/vsftpd/vsftp.conf you have an entry like:

chroot_local_user=YES
user_config_dir=/etc/vsftpd/users

Inside that directory (/etc/vsftpd/users) you have a config file with the same name as the user ($USER in your case), and inside that file you have:

local_root=/var/www/sites/USER
dirlist_enable=YES
download_enable=YES
write_enable=YES

...where USER is the actual name (not literally USER or $USER).

Solution 2

You must set user_sub_token:

user_sub_token=$USER
local_root=/var/www/sites/$USER
Share:
41,282

Related videos on Youtube

Pawel
Author by

Pawel

Updated on September 17, 2022

Comments

  • Pawel
    Pawel almost 2 years

    When I'm trying to connect to FTP server I get: "500 OOPS: cannot change directory:/home/$USER/public_html"

    • when I do echo $USER - I get proper username
    • seems like $USER isn't interpreted inside my /etc/vsftpd.conf
    • when I remove "local_root=/var/www/sites/$USER" I everything is smoothly working.

    I'm running vsftpd 2.2.2 and Ubuntu 10.04.1 LTS Release: 10.04 Codename: lucid

  • user3450548
    user3450548 over 5 years
    Fun that this is the actual real solution, what the original poster wanted to do was actually applicable. You can use it also in the other proposed example, but you don't need necessarly to enable user_config_dir. You can do it or you could not, depending on your taste. The important pass here is user_sub_token=$USER, because this is the one who fills the $USER var with something usable inside the conf. See the user_sub_token description in man page: "This option also takes affect if local_root contains user_sub_token."
  • user3450548
    user3450548 over 5 years
    The important pass here is use: user_sub_token=$USER, this makes the original poster configuration functioning because $USER variable get an usable value. See my comment in the other answer.
  • Kiruahxh
    Kiruahxh about 4 years
    It didn't work until I change the user home directory in /etc/passwd