Mount Remote Filesystems With SSHFS (Ubuntu)

SSHFS

For anyone that frequently accesses remote file systems or actively develops on remote servers, you may find this brief tutorial helpful.  SSHFS allows for mounting remote file systems over SSH.  For example you have a server, let’s call it foobar.com.  On this server you have your web root directory you want to access directly (/var/www/htdocs).  From your local machine you could simply go to /media/foobar.com and view the files contained on foosprinkle.com:/var/www/htdocs.  Here’s how…

Step 1:

$ sudo apt-get install sshfs

Note: It may fetch some dependencies.  This is okay.

Step 2:

Now go ahead and create a local directory for your mounted directory.  You’ll want permissions for that fresh directory so let’s do that as well.

$ sudo mkdir /media/foobar.com
$ sudo chown  yourusername /media/foobar.com

Step 3:

You are going to need to add your account to fuse group.  Not a problem, it’s simple.

$ sudo adduser yourusername fuse

Note: If you are running Ubuntu (perhaps others do this as well), you will need to logout and log back in.  For added security this is required in order for your system to recognize you in your newly added group.

Step 4:

$ sudo sshfs remoteusername@foobar.com:/var/www/htdocs /media/foobar.com

Note: You can easily unmount this drive by issuing yet another simple command :)

$ fusermount -u /media/foobar.com

Enjoy!

Leave a Reply