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

Asked by vesselin kavalov

sshfs joe@remote_server.com:/home /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 remote_server.com
...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 remote_server.com and tried:

sshfs joe@remote_server.com:/home /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 remote_server.com

...but on the remote_server.com (like ssh joe@remote_server.com; 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 ?!?!?)

vess

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu openssh Edit question
Assignee:
No assignee Edit question
Solved by:
vesselin kavalov
Solved:
Last query:
Last reply:
Revision history for this message
Hilario J. Montoliu (hjmf) (hmontoliu) said :
#1

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

HTH

--
hmontoliu <at> ubuntu.com
http://hmontoliu.blogspot.com

Revision history for this message
Hilario J. Montoliu (hjmf) (hmontoliu) said :
#2

-----BEGIN PGP SIGNED MESSAGE-----
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> ubuntu.com
http://hmontoliu.blogspot.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk0+500ACgkQk9xSKJO/Y0GhsgCeIRRI/1ItlF5Fk0ibolB5+KJx
mXIAoI0P1W0KOASwDmtHNxuOyv1UVvDe
=PZok
-----END PGP SIGNATURE-----

Revision history for this message
vesselin kavalov (vesselin-kavalov) said :
#3

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 joe@remote_server.com where:
user name: joe
user ID: 501
group ID: 10

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

peter-1001-22

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

joe-501-10

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

vess

Revision history for this message
vesselin kavalov (vesselin-kavalov) said :
#4

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

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

vess

Revision history for this message
vesselin kavalov (vesselin-kavalov) said :
#5

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 remote_server.com 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

vess

Revision history for this message
vesselin kavalov (vesselin-kavalov) said :
#6

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 :(

vess