Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like to use sshfs with many users.

sshfs root@192.168.56.100:/ 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
add comment

3 Answers 3

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
add comment

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)

Graham

share|improve this answer
add comment

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
add comment

Your Answer

 
discard

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.