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.
useradd someone
groupadd sftpusers
usermod -G sftpusers someone
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
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/