2

I am fully aware this question was asked countless times, but no solution mentioned before worked for my case.

My config:

$ cat /etc/vsftpd-anon.conf 
listen=YES
local_enable=NO
anonymous_enable=YES
write_enable=YES
anon_root=/var/anonftp
xferlog_enable=YES
listen_address=10.0.0.2
listen_port=9988
allow_writeable_chroot=YES

See, I am not using any home directory things. There is this one directory I created especially for this case. I also added allow_writeable_chroot option and vsftpd recognizes it, but IGNORES IT.

target directory:

$ ls -l /var/ | grep anonftp
drwxrwxrwx  3 root root      4096 led 26 11:09 anonftp

How I try to use it:

$ sudo killall vsftpd 
$ sudo vsftpd /etc/vsftpd-anon.conf &
[1] 21064
$ ftp 10.0.0.2 9988
Connected to 10.0.0.2.
220 (vsFTPd 3.0.2)
Name (10.0.0.2:david): anonymous
331 Please specify the password.
Password:
500 OOPS: vsftpd: refusing to run with writable root inside chroot()
Login failed.

Nothing in vsftpd.log

3
  • How did you solve this?
    – chaosguru
    Dec 14, 2017 at 13:17
  • @sudharma.puranik Please don't laugh, but I installed windows into virtual machine and used FileZilla. It was the best time-effective solution. Dec 14, 2017 at 20:41
  • oh I see that was quite a detour :)
    – chaosguru
    Dec 15, 2017 at 10:41

4 Answers 4

2

Run echo "allow_writeable_chroot=YES" >> /etc/vsftpd.conf && service vsftpd restart

2

I had the same problem and nothing helped. not:

  1. allow_writeable_chroot=YES at vsftpd.conf
  2. chmod to the ftp root directory

    so I made a strace to the vsftpd process and saw the following lines:

...
18825 chdir("/usr/share/empty")         = 0
18825 chroot(".")                       = 0
...

after changing the permissions on /usr/share/empty with

chmod 0644 /usr/share/empty

the error was gone.

3
  • 1
    Hours and hours of searching, only the above helped me ... thank you! Oct 21, 2018 at 22:23
  • May I ask you how did you make a strace to the vsftpd process? Oct 21, 2018 at 22:24
  • 1
    strace -p <pid of the proftp process> -f
    – 0x0C4
    Nov 6, 2018 at 10:01
0
echo "allow_writeable_chroot=YES" >> /etc/vsftpd.conf && service vsftpd restart

Run the above command every time when editing conf.

1
  • 1
    It's a copy paste of Gilles's answer isn't it? Jul 21, 2016 at 12:05
0

SHORT

In my case, with pretty same configuration, problem was that the newly created user didn't had it's own /home/{username} directory

LONG

In vsftpd.conf, I had that lines:

...
user_sub_token=$USER
local_root=/var/www/$USER
...

Not sure, but, it looks like vsftpd tries to log user into user's /home directory first, then on success it does chroot() to local_root, and because user didn't had it's own /home/{username} directory - it failed with error above.

So, by adding /home/{username} directory and setting user as owner - solved it!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .