This is a repost of an "off-topic" question on stackoverflow.
My scenario is:
I created a user and added that user to sudoers:
visudo
user ALL=(ALL) ALL
Then
sudo adduser user www-data
and
chown www-data:www-data -R /var/www
Did a service restart, then tried:
scp file user@ip:/var/www
Permission denied
The permissions I had applied for folders then files were (not wp-config.php
or .htaccess
):
drwxr-xr-x
-rw-rw-r--
I tried:
sudo chmod -R g+w /var/wwwI was then able upload files to
/var/www
, but this set permissions to 775
, so I ran:
find /var/www -type d -exec chmod 755 {} \;
Now I can edit files but not write to the folder via SFTP or SSHFS etc.
My question now is:
How do I write to /var/www without compromising security?