And one for Debian/Ubuntu 10.10 at least, using ACL, though it works the same on other Linux distributions with slight differences.
Create the users, sam and tom, having the home directories, /home/sam/ and /home/tom/.
Create the group, sftp, for the purpose of sharing files.
Make sure the users are in the sftp group.
Now use ACL (Access Control Lists) to refine permisisons.
First add the acl option to the mount options of the file system that contains the shared directory.
sudo -e /etc/fstab
You might see something like this (add the ,acl portion):
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx / ext4 defaults,acl 0 1
Then, remount the file system with acl enabled:
sudo mount -o remount,acl /
Install the ACL tools:
sudo apt-get install acl
Create a directory for the group to share files, maybe /home/sftp/; set permissions.
sudo mkdir /home/sftp
sudo chown -R root:sftp /home/sftp
sudo chmod 0775 /home/sftp
sudo chmod g+s /home/sftp
sudo setfacl -d -m u::rwx,g::rwx,o::r-x /home/sftp
Or, should these files NOT be available to "other" users (root and sftp group members only)?
sudo mkdir /home/sftp
sudo chown -R root:sftp /home/sftp
sudo chmod 0770 /home/sftp
sudo chmod g+s /home/sftp
sudo setfacl -d -m u::rwx,g::rwx,o::--- /home/sftp
If we wanted to restrict delete and rename from all but the user who created the file:
sudo chmod +t /home/sftp
To add another user to this group:
sudo usermod -a -G sftp $username