I'm mounting my /home directory remotely using sshfs. Since UIDs and GIDs aren't the same on the server and client, I'm using idmap=file
. Additionally, because of application requirements, I must mount all of /home rather than individual user directories.
sshfs_uids:
user1:1001
user2:1000
sshfs_gids:
user1:1001
user2:1000
Command to mount:
sudo sshfs -o nonempty -o transform_symlinks -o hard_remove -o allow_other -o nomap=ignore -o idmap=file -o uidfile=/root/sshfs_uids -o gidfile=/root/sshfs_gids root@myserver:/home /home
When reading files, everything works as expected (files that should be owned by user1:user1 are indeed so). However, when I write as user1, this happens:
user1@myclient:~$ touch foo
user1@myclient:~$ ls -l foo
-rw-r--r--. 1 root root 0 Jun 13 13:54 foo
My user writes files as root! Even doing a ls -l
from myserver turns up the same root ownership. I can fix it manually, though:
user1@myclient:~$ chown user1:user1 foo
user1@myclient:~$ ls -l foo
-rw-r--r--. 1 user1 user1 0 Jun 13 13:54 foo
Is it possible, using a sshfs or fuser option, to make it such that new files are owned by the user that created them? If not, can I make sshfs or fuser call a custom script every time a file is written so that I can fix the file's ownership using chown?
EDIT:
If neither of the above are possible, can anyone recommend some alternative remote filesystem software that is: