For this I added my user to the www-data group:
sudo usermod -a -g www-data your_user
I also changed the umask for my user in ~/.profile
:
umask 027
Change user:group for entire file system:
sudo chown -R your_user:www-data drupal_root
On Drupal root run:
sudo find drupal_root -type d -exec chmod -R 2750 {} \;
sudo find public -type f -exec chmod -R 640 {} \;
Change settings.php:
chmod 440 settings.php
Change the files directory so when files are created they use your_user:www-data:
sudo find files -type d -exec chmod -R 6770 {} \;
sudo find files -type f -exec chmod -R 640 {} \;