Google
Words of wisdom: A citizen of America will cross the ocean to fight for democracy, but won't cross the street to vote in a national election. -- Bill Vaughan
Home | Technology | SSHFS Howto
How to mount your drive over the internet using SSHFS
By Jonathan DePrizio

Introduction
SSH, or Secure Shell, is a technology that has been used for many years as a replacement for telnet. It allows you to control a computer remotely, either through an intranet or over the internet, and all traffic is encrypted, meaning that your ISP, or anyone looking at the datastream, can't tell what is being sent and recieved.

An add-on to SSH is sftp, or Secure File Transfer Protocol, which enables you to transfer files over the secure connection created by SSH. However, in order to do this you must use an sftp client, like gftp on Linux, or WinSCP on Windows. Since this method requires you to download a file in order to modify it, and then upload it again, it is hardly ideal in a situation where you want to use or modify remote files as if they are a part of your local drive.

SSHFS is a great program that allows you to mount a remote drive or directory, over any network (including the internet), and act as if those files are located on your local machine. This HowTo will explain the short and easy steps to do this.


The How-To:
First, on the remote machine (the one containing the drive or directories you wish to mount elsewhere):

1. Install sshd. This is included by default in most distrobutions of linux, but is available through package management if it is not. In debian-based systems, such as Ubuntu, use the following command:

sudo apt-get install openssh-server
1a. If you haven't done so already, make sure you've forwareded port 22 on your router! To get your local IP address, run /sbin/ifconfig


2. This step is optional. You may want to create ssh-keys, so that you don't have enter a password each time you mount the drive. This is particularly useful if you want to automount the drive using /etc/fstab.
There is a great howto on creating ssh keys located here.

3. Install SSHFS on the machine on which you want to mount the remote drive. Using apt, the command is:

sudo apt-get install sshfs
4. Mount the drive. This can be done one of two ways; the first being from the command line:

sshfs user@host:directory mountpoint
Where user@host is your username on the remote machine, and its IP address or URL; the directory is the directory you wish to mount (/home, for example); and mountpoint is the local directory you will use to contain the remote files (this directory must already exist, and can be created using the mkdir command).

Another option is to add a line to your fstab file, which will allow easier mounting, and mounting on startup. Append the following to /etc/fstab:

sshfs#user@host:directory mountpoint fuse user 0 0
The "user" argument allows the mount to be manipulated by users other than root. Some distrobutions may complain about a badly-formatted fstab on statup, but this is normal and will not harm your system.

Now you can mount your sshfs drive using

mount [mountpoint]
Further Information:

The SSHFS Homepage