I'm trying to set up an upload directory on my server, and having the hardest time doing so. Uploads to the directory need to be accessible to all other users on the system, but the user account that is to be used for uploading should have no access at all (aside from uploading, that is), so I'm chrooting the uploaduser account to their own directory only. I'm using FTP over SSH because of policy considerations, and I've got the following setup:
UPLOAD DIRECTORY:
/var/uploads/uploaduser/
(I'm using this because the uploaduser account is not a regular account and should not be treated as such; however, I'm wide open to other suggestions as to how to go about doing this.)
Permissions are set as follows:
/var/
drwxr-xr-x 25 root root 4096 Mar 30 10:04 var/
/var/uploads
drwxr-xr-x 3 root root 4096 Mar 23 12:22 uploads/
/var/uploads/uploaduser
drwx---r-x 3 root root 4096 Apr 4 10:14 uploaduser/
Now, when I use FileZilla or any other client to upload files to the uploaduser directory, I get a "permission denied" error. HOWEVER, if I change the ownership of the uploaduser directory or change its permissions, I get this error:
Couldn't read packet: Connection reset by peer
It seems to be a "damned if you do/damned if you don't" situation.
I've got the following setup in /etc/ssh/sshd_config
:
Match user uploaduser
ChrootDirectory /var/uploads/destiny/
AllowTcpForwarding no
X11Forwarding no
ForceCommand internal-sftp
I'm using VSFTP and it's working just fine for all other applications involving FTP over SSH.
ETA: I'm using an Amazon EC2 instance as my webserver, and it's running the Amazon Linux AMI.