SSHFS is part of the libfuse project.
SSHFS allows you to mount a remote filesystem using SFTP. Most SSH servers support and enable this SFTP access by default, so SSHFS is very simple to use--there's nothing to do on the server-side.
SSHFS is shipped by all major Linux distributions and has been in production use across a wide range of systems for many years. However, at present SSHFS does not have any active, regular contributors, and there are a number of known issues (see all issues and bugs in the SSHFS issue tracker). The current maintainer continues to apply pull requests and makes regular releases, but unfortunately has no capacity to do any development beyond addressing high-impact issues. When reporting bugs, please understand that unless you are including a pull request or are reporting a critical issue, you will probably not get a response.
Once sshfs
is installed (see the "Build and Install" section below) running it is very
simple.
sshfs -h # help menu
sshfs --version # see version
General command syntax:
sshfs [user@]hostname_or_ip:[directory] mountpoint
For example, to connect to the username "john" on a host at local IP 10.0.0.1
, mounting the host's
root directory (/
) in your local ~/mnt/sshfs
directory, you would do the following:
mkdir -p ~/mnt/sshfs # create the ~/mnt/sshfs directory, if it doesn't already exist
sshfs [email protected]:/ ~/mnt/sshfs
General syntax:
# For most systems, including Ubuntu
fusermount -u mountpoint
# For BSD and MacOS, and also works fine on Ubuntu
umount mountpoint
For the example above:
# For most systems, including Ubuntu
fusermount -u ~/mnt/sshfs
# For BSD and MacOS, and also works fine on Ubuntu
umount ~/mnt/sshfs
- It is recommended to run SSHFS as a regular user (NOT as root). For this to work, the mount point
must be owned by the user. Therefore, mounting into a
mount
ormnt
directory you create inside your home directory is a good practice. - If the username (
user@
part of the command) is omitted, SSHFS will use the local username. - If the directory is omitted (while keeping the colon
:
just before it), SSHFS will mount the (remote) home directory. - If you need to enter a password, SSHFS will ask for it (actually, it just runs
ssh
which asks for the password if needed).
Also, many ssh
options can be specified. See the manual pages for sftp(1) (man 1 sftp
) and
ssh_config(5) (man 5 ssh_config
). The remote port number (-oport=PORT
) is one of the many
ssh
options which works with sshfs
.
First, download the latest SSHFS release from https://github.com/libfuse/sshfs/releases. On Linux and BSD (as opposed to MacOS), you will also need to install libfuse 3.1.0 or newer. On MacOS, you need OSXFUSE instead. Finally, you need the Glib library with development headers, which should be available from your operating system's package manager.
To build and install, you must use Meson (version 0.38 or newer) and
Ninja. After extracting the sshfs
tarball, create a (temporary) build directory and run
Meson:
mkdir build; cd build
meson ..
Normally, the default build options will work fine. If you nevertheless want to adjust them, you can
do so with the meson configure
command:
meson configure # list options
meson configure -D strip=true # set an option
To build, test and install SSHFS, you then use Ninja. Running the tests requires the
py.test
Python module. It also requires configuring ssh keys for passwordless login to
yourself via localhost. See the detailed notes about ssh key generation and setup
below.
ninja
python3 -m pytest test/ # (Optional, but recommended) run the tests
sudo ninja install
Tested 22 Dec. 2020 on Ubuntu 20.04.
- Download and
cd
into the source code- To download the latest source code:
git clone https://github.com/libfuse/sshfs.git cd sshfs
- OR (recommended): To download the latest
sshfs
release:- Find the release you want here: https://github.com/libfuse/sshfs/releases.
- Find the link to the
*.tar.gz
file you want. Example: https://github.com/libfuse/sshfs/archive/sshfs-3.7.1.tar.gz. - Download, extract, and
cd
into it:wget https://github.com/libfuse/sshfs/archive/sshfs-3.7.1.tar.gz tar -xvzf sshfs-3.7.1.tar.gz cd sshfs-sshfs-3.7.1
- To download the latest source code:
- Install dependencies
sudo apt update sudo apt install meson cmake fuse3 libfuse3-dev libglib2.0-dev
- Create a build dir,
cd
into it, runmeson
, and build and link withninja
:mkdir build cd build meson .. ninja # this builds and produces the new `sshfs` executable
- (Optional, but recommended) test your new
sshfs
executable. [This also includes detailed notes about ssh key generation and setup].- Note: ssh key generation notes come from GitHub here.
For sample test output, see here.# install the `pytest` python3 module in case you don't already have it pip3 install pytest # install `sshd` sudo apt update sudo apt install openssh-server # Configure passwordless ssh key-based login so you can ssh into yourself # (via `localhost`) for testing; see GitHub link above. # 1. Generate a new public-private key pair. ssh-keygen -t ed25519 -C "[email protected]" eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519 # 2. Now add your new "~/.ssh/id_ed25519.pub" public key to your # "~/.ssh/authorized_keys" file so you can have key-based password-less # ssh sessions into yourself via `localhost` for testing. cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys # run the python3 tests in the "test" dir python3 -m pytest test/
- Install
sshfs
:- Normal method. This installs
sshfs
at/usr/local/bin/sshfs
, whereas your normal Linux distribution's executable is likely in/usr/bin/sshfs
.# To install sudo ninja install
- Alternative method. This technique simply creates a symlink to the executable in your
~/bin
dir so your Linux distro's install still remain's intact and untouched. (For Ubuntu).# "Install" via a symlink. Note: ensure you are in the same dir as the new `sshfs` # executable first. mkdir -p ~/bin ln -si "$(pwd)/sshfs ~/bin" . ~/.bashrc # re-source your .bashrc file to bring the ~/bin dir into your PATH # To "Uninstall" rm ~/bin/sshfs
- Normal method. This installs
- Check your version from another dir to ensure the installation worked correctly.
Sample version output:
cd ~ sshfs --version
SSHFS version 3.7.1 FUSE library version 3.9.0 using FUSE kernel interface version 7.31 fusermount3 version: 3.9.0
If you need help, please ask on the [email protected] mailing list. Subscribe at https://lists.sourceforge.net/lists/listinfo/fuse-sshfs.
Please report any bugs on the main parent project's (libfuse
's) GitHub issue tracker here:
https://github.com/libfuse/libfuse/issues.