Share a remote filesystem over SSH


You may already be familiar with NFS and Samba for sharing files over a network. While these are both great distributed filesystem solutions, they require extra configuration and setup overhead in order to get them to work. If you want quick and easy access to a remote filesystem then SSHFS may be your best shot.

SSHFS (Secure SHell FileSystem) is a file system for Linux capable of operating on files on a remote computer using just a secure shell login. It is based on sftp (SSH File Transfer Protocol). Setup is easy on the server side, since most servers support SSH out of the box there is nothing to do. On the client side, mounting the filesystem is as easy as logging in with SSH. The end user can seamlessly and securely interact with remote files as if they were local to your machine.

Advantages of SSHFS over NFS/Samba:

  • Utilizes SSH and is therefore very secure.
  • Allows secure access to remote filesystems outside of your local network.
  • Requires no special configuration on the server side.


  • Slightly slower, although the difference is fairly small.
  • Does not show filesystem usage statistics.
  • Requires a user account on the server side.
  • Not a true distributed file system, single point to point sharing.


The first step is to install SSHFS.

In Ubuntu:

or in Gentoo:

Create the mount point on your local machine. This is where you are going to access the remote filesystem.

Your user must have permission to access this mountpoint.

Start Sharing

Now use the sshfs command to mount the remote filesystem. If the username is different on the server you are connecting, use the “username@host:” format, otherwise you can simply specify “host:”.

If you are not using keys with SSH you will be prompted for a password.

Once you are finished you can easily unmount the filesystem.

as regular user:

or as root:


You can add an entry for this share to /etc/fstab to make the mounting process more seamless.

user – allow any user to mount this share.
noauto – stop the shared directory from being automatically mounted at startup.

If you want it automatically mounted, ensure that your SSH configuration uses keys and not passwords so it doesn’t ask for a password at startup. Once keys are in use you can safely remove the noauto option.

With fstab updated you can now mount the share as a normal user with this simple mount command. Again, if ssh is configured to use passwords you will still be prompted for one.