Mount Remote Filesystem with SSHFS on Debian

SSHFS is quite handy working on remote servers, when you need to copy files across systems. SCP is good, SSHFS is sometimes better. 

What is SSHFS?

Referencing the man page, SSHFS (Secure SHell FileSystem) is a file system capable of operating on files on a remote computer using just a secure shell (SSH) login on the remote machine.

The real-life benefit of SSHFS is that the end user can seamlessly interact with remote files being securely served over SSH just as if they were local files on his computer. On the remote machine the SFTP subsystem of SSH is used.


# apt-get update && apt-get install sshfs fuse


Load fuse kernel module:

# modprobe fuse

By default, our regular user, sandy, is not a member of the fuse group:

# grep fuse /etc/group

Add sandy to the supplementary fuse group:

# usermod -aG fuse sandy


# su -l sandy

Create a mountpoint to be used to mount a remote filesystem:

$ mkdir ~/temp

In the following example, we’re going to mount the entire root filesystem. You can mount specific remote directories of your choice, like /home or /tmp.

Mount the remote root filesystem:

$ sshfs [email protected]:/ ~/temp -C -p 12

Sandy is both a regular user on the local system as well as a regular user on the remote system. Parameters:

  1. -C : enables data compression on SSH link.
  2. -p : custom port to use for SSH connection.

The df output below shows how the mounted filesystem should look like:

$ df -hT | egrep 'File|temp'
Filesystem           Type         Size  Used Avail Use% Mounted on
[email protected]:/  fuse.sshfs    35G  6.2G   28G  19% /home/sandy/temp

To unmount the filesystem, do:

$ fusermount -u ~/temp

Related Posts

OpenSSH Server Installation and Configuration

Leave a Reply

Your email address will not be published. Required fields are marked *