Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to use sshfs with many users.

sshfs root@ root/

With this command I get the whole file system in the directory root/.

Is there any possibilities to change the user of a file when this user just exists on the remote machine ?

I tried:

chown myuser myfile

When I make ls -lah on the remote I get:

-rw-r--r-- 1 otheruser   root       0 Jan 11 11:03 myfile
share|improve this question
up vote 2 down vote accepted

The problem comes from the fact that chown will give the file to the user whose local UID belongs to myuser.

Say for example, on the local machine, you have myuser with UID 1001, but UID 1001 belongs to otheruser on the distance machine.

If you wanted to give it to myuser on the remote system, you would have to either:

  • Synchronize accounts/UID on both machines (using a centralized configuration manager can help);
  • know the distant UID of myuser (using e.g. ssh root@distant id -u myuser) and use chown with that UID.

Using the second option, you could do for example (using bash):

uid=$(ssh root@distant id -u myuser)
[[ -n $uid ]] && chown $uid. myfile || echo "No uid found. Not chowning"
share|improve this answer
I thought about your second solution for 20 minutes under my shower :p Thanks it works very well :) – charles Jan 11 '12 at 10:50

Look for the posixovl filing system.

Assuming ~/REMOTESITE is an sshfs mount of the remote system:

/usr/local/sbin/mount.posixovl -F -S ~/REMOTESITE/user-backups /REMOTESITE -- -o allow_other

(I'm not sure if the 'allow_other' is strictly needed but it doesn't hurt.)

The remote files remain owned by whoever is logged in to the remote account but to the local system they appear to be owned by local users.

(You might also want to layer encfs over this so you don't need to trust the remote site)


share|improve this answer

No you cannot do that. All the files on remote system are accessed as the "user" that is used while mounting it. In your case it is root .

share|improve this answer
it works with uid like Raphink said. – charles Jan 11 '12 at 11:02
yes of course file permission data in inode structure are uid,gid and these are mapped to users and group names. – daya Jan 11 '12 at 11:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.