Make /var/www accessible only for root and web server
I assume the Apache user is called www-data
. If you want the files in /var/www/
to become readable only by this user, you need to give it ownership:
sudo chown -R www-data /var/www/
Now you want www-data
to be the only user that can actually read/write those:
sudo chmod -R 700 /var/www/
Note that root
always has read/write access to any file, regardless of the permissions. Whether this setup is a good idea or not – well, I'd rather chroot these SSH users to their home folders. See Can I create an SSH user which can access only certain directory?
Related videos on Youtube
slhck
Updated on September 18, 2022Comments
-
slhck over 1 year
I'm a web developer. I'm allowing SSH access to my machine for a couple of people.
I want to make sure that they can't access my files in
/var/www/
.So is it possible to make these files readable only to the web server and give read/write access to the root user?