How to preserve file ownership when editing files over sshfs?
I administer a Ubuntu web server running a LAMP stack. I am now trying to mount the file system to a Windows machine over SSH (using win-sshfs). This works as expected.
However, when editing files and saving them, the owner and umask is overwritten. I'm not sure how to prevent this from happening.
For example, before an edit:
-rwxrwxr-x 1 root dev-ici 5594 Mar 3 12:33 install1.tpl
After an edit over sshfs:
-rw-rw-r-- 1 mririgo mririgo 5595 Aug 7 17:46 install1.tpl
I'm not sure if the problem is stemming from win-sshfs or from an configuration issue on the server.
There may be more information I would need to provide to help track down the exact issue. If so, please leave a comment and I'll gladly provide it.
You can use -o idmap=XXXX uidfile=FILE gidfile=FILE
where the files contain maps between the UID/GIDs for the two boxes.
Or have NSS configured on the Ubuntu box to pull user information from your domain (assuming Active Directory on the Windows side).