sshfs: how to match uid and gid on the remote server

Asked by vesselin kavalov on 2011-01-25

sshfs /joe_s_remote_home

Everything ran OK and the mount happened.

What will the uid, gid and file permissions will be if I:

touch /joe_s_remote_home/test

I would expect to be exactly the same as if I was logged as joe sitting in front of the
...but isn't for me (sshfs from Ubuntu 10.04 to Redhat 4.6 machine)

Then I found joe's uid and gid on the and tried:

sshfs /joe_s_remote_home -o uid=joe_s_uid_over_there -o gid=joe_s_gid_over_there

and touched again.

When I 'ls -l /joe_s_remote_home/test' from the near end - it shows the right uid and gid for joe on

...but on the (like ssh; ls -l /home/test ) shows some irrelevant uid and gid for the file.
and it is created with 400 permissions. Now I cannot do anything with this file from either side, since it belongs to a non-existent user.
I cannot remove it. Nothing!

So, what is the "right" way of sshfs-ing that gives me the expected behavior - i.e. :

I gave you a valid user name on a valid server and I EVEN gave you the right password! So can I get a mount that I can actually use? (WTF ?!?!?)


Question information

English Edit question
Ubuntu openssh Edit question
No assignee Edit question
Solved by:
vesselin kavalov
Last query:
Last reply:

Hi vesselin kavalov,

Can you post the real uid/gid just to get an idea.

w/o testing it this is what I would expect:

* user hmontoliu in ubuntu may have an uid of 1001
* user hmontoliu in redhat may have an uid of 501

So if I see the redhat mounted partition from the ubuntu side the uid of the stuff in there will be 501 as there is no local user with that uid to map the name back.

You logged (mounted) the redhat partition with the user "hmontoliu" which has a local uid of 501. However as the partition is mounted in ubuntu and there is a 501 user ubuntu doesn't map back the name, so you just see the uid.

Yo can create a user in both systems with the same uid and then you'll see its name either in ubuntu or in redhat


hmontoliu <at>

Hash: SHA1

El 25/01/11 14:25, Hilario J. Montoliu (hjmf) escribió:
> ubuntu and there is a 501 user ubuntu doesn't map back the name, so you
                   ^ isn't

- --
Hilario J. Montoliu
hmontoliu <at>
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla -


Hi Hilario,
My problem is NOT that I cannot see user names from the opposite machine. I don't even have to have the same user name/uid/gid on both machines.

The problem is that once I sshfs a directory on the remote_server as an existing user of the remote_server, I expect all the files that I create from the local machine in the mounted remote directory to have the remote user name/uid/gid since that's how I sshfs-ed to that machine.

On the local machine I am:

user name: peter
user ID: 1001
group ID: 22

I sshfs as where:
user name: joe
user ID: 501
group ID: 10

If I touch a file somewhere on my local machine, the ownership is:


If I touch a file from the local machine through the sshfs mounted directory on the
the ownership SHOULD BE:


BUT IT ISN'T! ...and that's what I am asking, how to make it be!


.... just to make clear: the ownership ON the AS SEEN ON the, where 'joe' does exist with uid=501 and gid=10.

So, joe on the can read, write, execute, delete ans so on... the file that was created from 'peter's' local machine AS 'joe' through sshfs


Found a little bit more:

My Ubuntu that I am sshfs-ing from runs as a virtual machine under VirtualBox 4.0.2 on my Mac laptop. I just noticed that the mysterious uid and gid that the files were getting created on the were actually my Mac ones - I have the same user name on all three machines, but all different uid-s and gid-s.

But why the Mac ones? The virtual machine ethernet is supposedly tunneling through and shouldn't even know about the Mac host ?!?! - Actually this started happening AFTER I upgraded VirtualBox from 3.10 -> 4.0.2! I think Oracle goofed-up something around the networking of the VMs


Actually I removed the '-o uid=xxx -o gid=yyy' from the command line and it worked like a charm!
Sorry for the false alarm :(
I needed the uid and gid explicitly set with VB 3.10, but looks like it is counter-productive with VB 4.0.2

Again, sorry for the noise :(