Linux – How to Mount Local Directory to Remote Like SSHFS

linuxmountremotessh

I know sshfs is used to mount remote directory to local, but I need to mount local directory to remote fs.

I would like to mount a local folder such as:

/home/username/project_directory

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

/var/www/project_directory

The goal being that edits made locally are reflected on the remote filesystem.

Best Answer

from: http://mysteriousswede.blogspot.com/2012/01/mount-local-directory-to-server-on.html

How to do it? You set up ssh forwarding by using port 10000 on the machine you log in on to port 22 on your local machine and use sshfs to mount in on the other side.

F.ex. to mount /home/username/mywwwdevelstuff on your local machine to /var/www on the server side:

localusername@localmachine: ssh username@server -R 10000:localmachine:22
username@server: cd /var
username@server: sshfs -p 10000 -o idmap=user,nonempty \
                 localusername@127.0.0.1:~/mywwwdevelstuff www
Related Question