Accessing Remote Drive in Linux via SSHFS

There may be a case where you may want to access a certain directory or drive on a remote machine, and mount it to your local PC. For example, I have a headless CentOS box running Apache where all of my web application codes are sitting. Editing those web application codes are a nightmare when there is no Integrated Development Environment (IDE). I can install IDE (like Eclipse) on my Ubuntu box, but I need a way to map the remote /www folder to my local Ubuntu folder. This is very easy in Linux using sshfs.

http://en.wikipedia.org/wiki/SSHFS
https://help.ubuntu.com/community/SSHFS

Install sshfs:
$sudo apt-get install sshfs

Create your local directory and change the permission:
$sudo mkdir /media/directoryname
$sudo chown your-username /media/directoryname

Where “directoryname” is the name of the directory on your local computer where you want to access the files from the remote computer. Let say I want the files on the server to be available at /media/directoryname.

Add yourself to the group “fuse”.
$sudo adduser your-username fuse

To mount the remote directory to your local:
$sshfs your-username@myserver:/www/html ~/directoryname

To unmount:
$fusermount -u ~/directoryname