So the problem is that
www-data needs to have write permission to some of the files and folders you upload. It would be good to know which files WordPress requires write permission to and only give it to those files.
There is a less secure solution which involves giving write permission to only your user and
First lets take care of the initial permissions.
sudo chown -R tokar86a:www-data /var/www
/var/www so every file created in it will inherit it's group ID.
sudo chmod g+s /var/www
Now make sure that uploaded files will get
rw- rw- --- permissions. Open
sudo nano +77 /etc/ssh/sshd_config
Find the line
Subsystem sftp /usr/lib/openssh/sftp-server and append
-u 017 to it.
Subsystem sftp /usr/lib/openssh/sftp-server -u 017
Save the file and reload SSH to activate the modification.
sudo reload ssh
Reconnect to SFTP and the problem should be solved. Uploaded files should be owned by your user. The group should be
www-data and the permission should be
rw- rw- ---.
If you want to retain read permission to world you can use
013 instead of