You are not logged in.

#1 2019-02-23 13:00:26

ducksys
Member
Registered: 2019-02-23
Posts: 2

Mounting an sshfs path from inside a network namespace

Hello,

I can't figure out why the mount point remains empty when I try to mount a remote path with sshfs from within a network namespace.

ip netns exec <namespace> sshfs <username>@<address>:/remote/path /path/to/mountpoint

I get no error messages at all, and the mount point remains a normal empty directory, and the mount doesn't show up in the list when using the mount command.

  • the alternate network inside the namespace is configured with a macvlan interface and it works correctly with everything else

  • sshfs -f --debug shows no errors

  • -o allow_other doesn't help, as that will come into play later I think

  • also tried rclone mount with a cloud provider, same result

  • both sshfs and rclone mount work fine in the default network namespace

I'm assuming that this has something to do with fuse and network namespaces but can't find any specifics/solutions for my case.

I would appreciate any help.

Offline

#2 2019-05-17 13:17:59

couling
Member
Registered: 2019-05-17
Posts: 4

Re: Mounting an sshfs path from inside a network namespace

Apologies for digging up an old post.  I stumbled on this question while trying to find an answer a similar one https://unix.stackexchange.com/question … fs-doesn-t.

This is, unfortunately, expected behaviour.


http://man7.org/linux/man-pages/man8/ip-netns.8.html

ip netns exec automates handling of this configuration, file
       convention for network namespace unaware applications, by creating a
       mount namespace and bind mounting all of the per network namespace
       configure files into their traditional location in /etc.

This means that when you use...

ip netns exec <namespace> <command>

... the command will not only execute in a different network namespace but also a different mount namespace.  So sshfs is successfully mounting as you request, but you can't see that mount.

The simple workarounds are to do everything from within the same network namespace

    ip netns exec secured bash
    sshfs -d -o sshfs_debug -p PORT USER@HOST: MOUNTPOINT
    # ... use MOUNTPOINT

Or, after creating the share, you can re-enter that mount namespace:

    ip netns exec secured sshfs -d -o sshfs_debug -p PORT USER@HOST: MOUNTPOINT
    ps -ef | grep sshfs
    root 1880     1  0 13:15 ?        00:00:00 sshfs -p PORT USER@HOST:. MOUNTPOINT

    # Now run a command (ls) in the same mount namespace
    nsenter --mount -t 1880 ls

    # You can of course run a command prompt there
    nsenter --mount -t 1880 bash

Last edited by couling (2019-05-17 13:18:33)

Offline

#3 2019-08-13 11:12:55

ducksys
Member
Registered: 2019-02-23
Posts: 2

Re: Mounting an sshfs path from inside a network namespace

I had no clue about mount namespaces!

nsenter is the key here, many thanks couling!

Offline

Board footer

Powered by FluxBB