Web Design / Development
SFTP write access when files owned by www-data
22 July 2012
Ubuntu users will recognize this common issue;
You have a user directory, e.g. /home/someuser, and you can SSH in and use 'sudo -s' to do super-usery things. Now try to SFTP (Dreamweaver, FileZilla, etc), and you can download, but if the files are 'owned' by www-data you probably can't upload anything except maybe new files. Many web applications (Drupal at least) need the files to be writable by the same user/group that Apache uses /... in the case of Ubuntu this is www-data.
You can't use 'sudo -s' within Dreamweaver or FileZilla.. yes, FileZilla has a custom command option, but it doesn't work with 'sudo -s'.
You can "chown someuser:someuser * -R" inside the /home/someuser directory and make them writable by your user that way, but then you would need to chown them back to www-data to keep Drupal running well.
A long-term solution is this:
sudo usermod -a -G www-data someuser
Then ... log that user out of the FTP client and try again. You have to log out for the new permissions to be recognized.