How to Mount Remote Directories with SSHFS


Please shareShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on RedditDigg thisShare on StumbleUpon

Recently, I was demonstrating ssh tunneling to some of my students. One of them asked me how they access remote directories in GUI. This can be achieved in several ways. Let us try mounting via ssh.

Install the sshfs package on the machine you want to mount the remote directory.

 $ sudo  apt-get instlall sshfs

You need ssh server running on the remote machine and you must have a valid username and password on that machine.
In the example below, I am assuming that you have an account named ubg on a remote_server . Replace remote_server with its IP address. /home/ubg/remote is the local folder into which the remote folder will be mapped. Now let us mount the remote directory.

$ sudo sshfs ubg@remote_server:   /hume/ubg/remote

This will mount the home folder of the user ubg on remote_server to the folder /home/ubg/remote on the local machine. You can mount any folder on which you have read permission to the local machine. See this example.

$ sudo sshfs ubg@remote_server:/usr/share/doc /hume/ubg/remote

Now, you can access the remote folder via nautilus like a local folder.

You can unmount the remote folder with

$ sudo fusermount -u /hume/ubg/remote