I have an Ubuntu VPS (LAMP) and I manage the PHP files from the www folder via SFTP.
I use Wordpress on my server, with it I upload folders and files and also delete them. Via Wordpress when I do a new upload of a folder or file and later try to delete or edit the contents of some file directly via SFTP the server returns me access denied. If I send the file or folder directly via SFTP the server allows without problems.
Every time I upload a folder or file via Wordpress and need to manually change the folder or files via SFTP, I need to run the following command for the server to not return access denied:
sudo chown -R usuario:www-data /var/www
Why does this happen? I configured permissions incorrectly? When I use Wordpress to upload, does it generate the folder and files with different permissions?