Skip to content

A network filesystem client to connect to SSH servers

License

Notifications You must be signed in to change notification settings

ElectricRCAircraftGuy/sshfs

 
 

Repository files navigation

SSHFS

About

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.

Development Status

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.

How to use

Once sshfs is installed (see the "Build and Install" section below) running it is very simple.

sshfs -h         # help menu
sshfs --version  # see version 

1. To mount a remote filesystem with sshfs:

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

2. To unmount the remote filesystem:

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

3. Notes:

  1. 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 or mnt directory you create inside your home directory is a good practice.
  2. If the username (user@ part of the command) is omitted, SSHFS will use the local username.
  3. If the directory is omitted (while keeping the colon : just before it), SSHFS will mount the (remote) home directory.
  4. 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.

Build and Install

1. General overview

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

2. Detailed instructions

Tested 22 Dec. 2020 on Ubuntu 20.04.

  1. Download and cd into the source code
    1. To download the latest source code:
      git clone https://github.com/libfuse/sshfs.git
      cd sshfs
    2. OR (recommended): To download the latest sshfs release:
      1. Find the release you want here: https://github.com/libfuse/sshfs/releases.
      2. Find the link to the *.tar.gz file you want. Example: https://github.com/libfuse/sshfs/archive/sshfs-3.7.1.tar.gz.
      3. 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
  2. Install dependencies
    sudo apt update
    sudo apt install meson cmake fuse3 libfuse3-dev libglib2.0-dev
  3. Create a build dir, cd into it, run meson, and build and link with ninja:
    mkdir build 
    cd build 
    meson ..
    ninja  # this builds and produces the new `sshfs` executable

  1. (Optional, but recommended) test your new sshfs executable. [This also includes detailed notes about ssh key generation and setup].
    1. Note: ssh key generation notes come from GitHub 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/
    For sample test output, see here.
  2. Install sshfs:
    1. 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
    2. 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
  3. Check your version from another dir to ensure the installation worked correctly.
    cd ~
    sshfs --version
    Sample version output:
    SSHFS version 3.7.1
    FUSE library version 3.9.0
    using FUSE kernel interface version 7.31
    fusermount3 version: 3.9.0
    

Getting Help

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.

About

A network filesystem client to connect to SSH servers

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages

  • C 84.4%
  • Python 11.7%
  • Shell 1.8%
  • Meson 1.7%
  • Emacs Lisp 0.4%