2

Local: OpenSUSE, mount point /home/gruz/debian

Remote: Debian (VirtualBox) 192.168.0.100, mount point /var/www/a

I want to mount folder in 192.168.0.100:/var/www/a to my local machine so when I create a file/folder at the mounted folder at my local machine it's created with www-data:www-data at the server (which is 33:33 at Debian).  But it's created with root:root owner (0:0).

At my local OpenSUSE I make sure I have correct owner:

sudo chown 33:33 /home/gruz/debian

Next I mount it like this:

sudo sshfs -o uid=33,gid=33,allow_other [email protected]:/var/www/a /home/gruz/debian

If I mkdir a folder at the mount, it's created with 33:33:

gruz@linux-k9eu:~/debian> ls -lan
total 16
drwxr-xr-x  1   33  33 4096 Apr 28 16:13 .
drwxr-xr-x 41 1000 100 4096 Apr 28 16:08 ..
drwxr-xr-x  1   33  33 4096 Apr 28 16:10 aa
drwxr-xr-x  1   33  33 4096 Apr 28 16:13 bb

But at the server I see 0:0:

root@debian:/var/www/a# ls -lan
total 16
drwxr-xr-x 4 33 33 4096 Apr 28 09:13 .
drwxr-xr-x 6  0  0 4096 Apr 28 09:09 ..
drwxr-xr-x 2  0  0 4096 Apr 28 09:10 aa
drwxr-xr-x 2  0  0 4096 Apr 28 09:13 bb

And what is strange when I run mount -v at my local machine, I can see

[email protected]:/var/www/a on /home/gruz/debian type fuse.sshfs (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other)

So sshfs seems to ignore uid=33,gid=33,

Please, give advice.

1 Answer 1

2

On the remote machine the files are created with the user you use to login. The output of mount -v shows that you login as root. Use sshfs [email protected]:/var/www/a /home/gruz/debian to mount the remote directory.

The -o flag changes the uid/gid of the remote files on the local machine. You could run the sshfs command as the other user if you would want him to own the mountpoint. There is no need for that if you want to work with the files with the user gruz.

3
  • I cannot use [email protected] because www-data at debian is very tricky to make loginable. And insecure. In other words I want to work with files as gruz, I can login as root and I want the new files to be saved as www-data. Is this possible at all? I need to edit remote files from my localhost (as from a refular folder to be able to use my IDE) and not care of chown at the server each time I create something. Apr 28, 2017 at 15:59
  • I don't think root is better, you should use gruz: serverfault.com/questions/158392/how-do-i-sudo-over-sshfs
    – ctx
    Apr 28, 2017 at 17:03
  • Thanks for the hint. I'm so tired with the problem, that I have enabled www-data login. I have no passion to try the link now. But thanks for it, I'll try it later. Apr 28, 2017 at 21:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .