Linux ubuntu vsftpd how to add users to manage apache www web folders

After you have installed vsftpd using (sudo apt-get install vsftpd)

Find /etc/vsftpd.conf

Inside enable the following flags

# Enable this to allow users to write files to their web folder
write_enable=YES

# To restrict users to specific web folders and block access to parent folders
chroot_local_user=YES

# You may want to enable passive mode if you have a firewall
pasv_enable=YES
pasv_min_port=65000 (example, set your own)
pasv_max_port=65535 (example, set your own)

# Also remember to open up port 20 for FTP-DATA, 21, and 990 for TLS/SSL on your firewall

Next create your users and add them to the web group

useradd -s /usr/sbin/nologin {new_username}

sudo passwd {new_username} # you will be prompted to enter a password twice

sudo usermod -d /var/www/{web folder} {new_username}

usermod -a -G www-data {new_username}

Next do the following:

vi /etc/shells

# Add the following to the last line:

/usr/sbin/nologin

# Save that.

# Finally, restart your ftp server

service vsftpd restart

Now test your new web ftp user account and check if the directory is writable and also make sure the pages are viewable in a browser.

Anyway, thats how I did it and got it to work. Otherwise the published pages don’t display and a permission denied error appears because www-data cannot execute the files.

How to hide Parent directories settings:

dirmessage_enable=YES
anonymous_enable=NO
anon_world_readable_only=YES
syslog_enable=YES
connect_from_port_20=YES
pam_service_name=vsftpd
listen=YES
ssl_enable=NO
anon_mkdir_write_enable=NO
anon_upload_enable=NO
chroot_local_user=YES
ftpd_banner=Welcome message
idle_session_timeout=900
local_enable=YES
log_ftp_protocol=NO
max_clients=10
max_per_ip=3
pasv_enable=YES
pasv_max_port=40500
pasv_min_port=40000
ssl_sslv2=NO
ssl_sslv3=NO
ssl_tlsv1=YES
write_enable=YES
download_enable=YES

If you get the following error:

500 OOPS: vsftpd: refusing to run with writable root inside chroot

Then install the following:

1. sudo apt-get install python-software-properties

2. sudo add-apt-repository ppa:thefrontiergroup/vsftpd

3. sudo apt-get update

4. sudo apt-get install vsftpd

5. vi /etc/vsftpd.conf and add the following
allow_writeable_chroot=YES

6. sudo service vsftpd restart

One Response to Linux ubuntu vsftpd how to add users to manage apache www web folders

  1. Vworkers4u says:

    Thank you so much!!!

Leave a reply to Vworkers4u Cancel reply