Enable non root user to upload/download onto website directory

I have a website in my VPS. I install Debian 7 on that VPS. My http document is located in directory /var/www/example.com I installed Nginx on that server and directory /var/www/example.com is owned by user www-data and group www-data. I want to add non root user (let's name it someone) to be able to download or upload documents onto that directory through FTP or SFTP client like FileZilla.

I found this and this guide explaining it can be done using chroot. I try to configure it but it didn't work. Here's some command that I used so far.

  1. useradd someone
  2. groupadd sftpusers
  3. usermod -G sftpusers someone
  4. vi /etc/ssh/sshd_config

I added this code

#Subsystem sftp /usr/lib/openssh/sftp-server
Subsystem sftp internal-sftp

And at the end of file I added

Match group sftpusers
    ChrootDirectory /var/www/example.com
    X11Forwarding no
    AllowTcpForwarding no
    ForceCommand internal-sftp
  1. service ssh restart

But when I conected through FileZilla, it gave me error. I suspect this error due to /var/www/example.com is owned by user www-data and group www-data.

Question: How to enable non root user to be able to download or upload document onto /var/www/example.com directory through FTP or SFTP client like FileZilla. This non root user should not be able to access parent directory like /var/www/


OH for the love of all things cute & cuddly, do not set 777 permissions on ANYTHING that is accessible to world+dog (i.e. your website directories, anonymous ftp folders).

Modern Linux and BSD has per user ACLs that you can set and they work perfectly! You can use this to add rwx for specific users and specific groups as well. It's super easy to do once you understand them!

TLDR; use the setfacl command as follows #setfacl -m someuser:rwx /public_html SHAZAM! Now someuser has read/write/execute on your public_html directory I would encourage you to read the man page for setfacl or at least a HOWTO to get familiar with the functionality of it. Here's a simple introduction to filesystem ACLs: https://www.redhat.com/sysadmin/linux-access-control-lists

it's great for webservers where you need to allow specific developers who have their own accounts access without granting rwx to world+dog.