2

I know we can use sshfs to mount a remote machine directory on a local machine, but, Is the reverse possible. I want to edit the files on my local system and do not want them to reside permanently on the remote server.

I tried this (https://github.com/agirorn/mount-on) doesn't seem to work.

I would like to mount a local directory like:

/Users/username/sshfs_share_folder

onto a remote machine which I have ssh access to, such as:

/home/username/shared_folder
  • It should be possible if you have ssh daemon running on you Mac. – Philippe Jul 15 '20 at 13:28
  • I really don't understand why this question is closed. It's about a particular tool, not specific to hardware. But, I searched the internet there is no straight forward answer for this question. But, I will leave the option of opening the question to you guys, anyway, my issue got resolved. I personally think this could help many folks. – Manoj vardhan reddy Jul 21 '20 at 03:34

1 Answers1

5

Assuming the local machine is behind a NAT and cannot directly ssh to local machine from remote machine, run a reverse ssh tunnel on the local machine using remote port forwarding.

# on local machine
ssh -R 2222:localhost:22 <remote-user>@<remote-addr>

Now, on the remote machine , you can use sshfs to mount a dir from the local machine by pointing it to localhost:2222 which internally tunnels the request to the local machine at port 22.

# on remote machine
sshfs -p 2222 <local-user>@localhost:<local-dir> <remote-dir>
avinash
  • 66
  • 4