There are many similar questions here, and I've followed several answers to try and solve this issue, but with no luck.
I'm using Ubuntu 14.04.5 LTS on an EC2 instance at AWS. I'm using WordPress in /var/www/html/folder. I'm logged in as the user ubuntu on both SSH and SFTP.
All files and folders in /var/www/html/folder were group-owner ubuntu, and I needed to change all those to the apache user www-data for WordPress.
First, I added the ubuntu user to www-data:
sudo usermod -a -G www-data ubuntu
and I logged out and in, and so using
getent group shows
Then, I changed all files/folders in /var/www/html/folder from the default ubuntu to the www-data group and owner with
sudo chown -R www-data /var/www/html/folder/
sudo chgrp -R www-data /var/www/html/folder/
sudo chmod -R g+s /var/www/html/folder/
And enabled all new files/fodlers to be in www-data with
sudo chmod 2750 /var/www/html/folder/
WordPress can now read/write, so I can add plugins and media from WP admin. And I can edit files on SSH as ubuntu using nano.
The problem is that I still can't upload, delete or edit files/folders with SFTP as the ubuntu user.
What do I need to do?