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

link|improve this question
feedback

2 Answers

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).

link|improve this answer
Thank you this solved a problem I had. – CYREX Oct 29 '11 at 19:31
feedback

When you run "echo $USER", your shell is expanding $USER into your username.

Your shell isn't parsing the vsftpd config file, vsftpd is, so there's no particular reason to think that $USER should be expanded the same way inside that file.

You didn't mention what you're trying to achieve so I can't give any advice there. I suspect the "chroot_local_user" might accomplish something close to what you're trying to achieve here.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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