I have a VPS running ubuntu 12.04 that is hosting about 9 sites which are a mix of wordpress and joomla (latest versions).
Apache runs under www-data and sites are hosted as virtualhost under /var/www/{sites}
Today I disabled FTP (insecure) and replaced it with SFTP. I've set this up so that every site/virtualhost has a SFTP user that is chrooted. when you login as SFTP user you get chrooted into /usr/local/chroot/{user}, in this directory i've mounted the specific virtualhost this user needs access to (with mount --bind /var/www/{subdomain} /usr/local/chroot/{user}/web)
the SFTP users are setup so that they can only SFTP and not SSH and their shell is set to /sbin/false
the only problem/question I have is with the user permissions. the sites run as www-data so when I upload something in for example joomla the file is created with www-data:www-data ownership. however if i upload a file using SFTP it's uploaded as {user}:www-data. this can lead to problems with permissions.
what would be the best way to handle file-ownership and permissions in this case? Also is the way I set this up safe?