Remote Storage: sshfs

Where Can I Use sshfs?

sshfs would be used to any system you can open an ssh connection to. This is the default way to long in to a shell session on a UNIX or Linux system. Right now, this would include SDF, as well as most of my personal systems.

Any prerequisites for sshfs?

Using sshfs

The basic command line is:

sshfs remote-user@remote-hostname:full-remote-path target-directory

You will be prompted for the password associated with the remote user on the remote system. Enter it, and the remote path will be visible locally at the target directory.

An example:

sshfs ~/

jbleaux's home directory on will be mounted locally in the local user's home directory, under the directory locally.

For some local systems, the permissions will not default to the local user, but to a local sysadmin. SDF, for instance, has this quirk. To resolve this, the options -o idmap=user -o gid=500 will need to be utilized:

sshfs remote-user@remote-hostname:full-remote-path target-directory -o idmap=user -o gid=500
You might also have to indicate the uid of the local user, in order to mount properly:
sshfs remote-user@remote-hostname:full-remote-path target-directory -o idmap=user -o uid=501
This will mount the drive with the owner the same as the local user specified by UID of 501. To find your local UIDs, run id -a.

If .ssh/config has entries for the system in it, you can simplify it with just the associated name. For instance, if I have an entry for like this:

  Host foo
    User jbleaux
The command can be simplified to:

sshfs foo:/home/jbleaux ~/

Unmounting sshfs

To unmount an sshfs volume, type:

fusermount -u target-directory

So, to unmount our example:

fusermount -u ~/

Conventions for Remote Storage Guides.
Return to Reference Index

Created by I. Charles Barilleaux
Last Update: 2021-04-11