I've got a Debian 8 server running where /var/www
is owned by www-data
and has the permissions drwxr-xr-x
for both, files and subdirectories.
Since I need to upload files via SFTP (public/private key authentication; password and non-encrypted FTP is blocked) I thought it should be no problem to add my user account to the group www-data
. Thus, I exectued:
sudo usermod --append --groups www-data my-user
I already logged out of the current SSH session in order to trigger a reload of the permissions. id my-user
now shows:
uid=1000(my-user) gid=1000(my-user) groups=1000(my-user),33(www-data)
However, I am still unable to write data via SFTP in /var/www
. Even a simple touch test.txt
directly via SSH fails with Permission denied
.
I thought rwx
is read
, write
and execute
. Obviously my understanding of the directory/file permissions is incomplete. Can someone help?
Best Answer
You state the permissions for /var/www are
drwxr-xr-x
which isrwx
for owner only. Group hasr-x
which means even though you added yourself to thewww-data
group, the directory does not allow the group write permission to /var/www.chmod g+w /var/www
to allow your account to be able to add files to /var/www.If there are any subdirectories beneath /var/www, you will want to do the same
chmod
command if you need to be able to write to those directories ever.Also consider setting the group sticky bit so all files created in /var/www will have
www-data
as the group.chmod g+s /var/www
Again, for any subdirectories underneath /var/www, you will want to add this as well.