Fuse Sshfs Windows



  1. Win Sshfs For Windows 10
  2. Sshfs
  3. Windows Fuse Sshfs

SSHFS-Win is a minimal port of SSHFS to Windows. Under the hood it uses Cygwin for the POSIX environment and WinFsp for the FUSE functionality.

In this tutorial I will guide you through the steps to set up SSHFS for sharing folder(s) among your servers. We will use autossh which has the nice 'automatic reconnect' capability. Also included are settings such as 'chroot' and 'SSH key restrictions' which will strengthen security.

These instructions have been fully tested on Ubuntu 14.04/12.04, Debian 8/7 and CentOS 6 servers. However, use at your own risk. Note for OpenVZ VPS users ONLY: You must ask your VPS provider to enable FUSE.

First, you need to decide on a 'master' server where your shared folder will be physically stored. Your other 'slave' server(s) will connect to it via SSHFS to share that folder's content. For the purpose of this tutorial, the folder to be shared on the master server is located at /opt/sshfs_export, while each slave server will hold its content in /opt/sshfs.

All commands below should be run as 'root', unless otherwise noted. Alternatively you may use 'sudo'.

The first step is to install the necessary software packages.

  1. Connecting SSHFS from Windows 10 With SSHFS, you can mount any SSH-ready host machine as a share driver securely via SSH communications. This ensures the communications is private and confidential between you and the host machine and not others. This section guides you through on how to establish a connection with the host server.
  2. SSHFS (Secure SHell FileSystem) is a file system for Linux (and other operating systems with a FUSE implementation, such as Mac OS X or FreeBSD) capable of operating on files on a remote computer.

For Ubuntu/Debian:

For CentOS/RHEL:

The instructions below are for both Ubuntu/Debian and CentOS/RHEL.

Create fuse.conf, set correct owner and permissions:

Note: Any logged in user on your server(s) will have full access to the mounted SSHFS folder. This is because we added user_allow_other to fuse.conf, and specified allow_other in the SSHFS command below.

Add user autossh and ensure it's a member of the fuse group:

Prepare the folder which will hold shared content:

Switch to user autossh and create an SSH key pair for authentication:

Now, repeat ALL steps above on your other 'master' AND 'slave' servers until they are fully set up.

Next, log on to each 'slave' server, and do:

Copy the above command's output and paste into your favorite editor. You should get one line for each 'slave' server, beginning with ssh-rsa and ending with autossh@YOUR_HOSTNAME.

In the editor, prefix every line with this (without the quotes):

This will strengthen security so that only SFTP is permitted. If you need to allow port forwarding, replace the no-port-forwarding to something like permitopen='127.0.0.1:8888', where 8888 is the port to be allowed.

Go back to your 'master' server. Run commands:

Copy and paste the entire contents of your favorite editor into nano, Ctrl-O and Enter to save, Ctrl-X to exit.

Prepare the folder to be shared on 'master' server:

Win Sshfs For Windows 10

Edit SSH configuration on 'master' server:

Make sure the settings below are all correct. If any line is missing, add it. In addition, if you see any AllowUsers line in the file, be sure to append autossh to it. Otherwise there is nothing to worry about:

Then add the following lines at the very end of the file, Ctrl-O and Enter to save, Ctrl-X to exit nano:

If you need to allow port forwarding, replace the last line above with these two lines, where 8888 is the port to be allowed:

Reload SSH configuration on 'master' server with:

Now you are almost done! Login to EACH 'slave' server and run these commands to save the master server's host key. Replace these variables with actual values: MASTER_SERVER_IP and MASTER_SERVER_SSH_PORT.

Finally, mount the SSHFS shared folder using this one-liner. Be sure to replace the two variables as stated above. To improve performance, you may optionally add Ciphers=arcfour128 to SSHFS options (References: [1][2]).

You can then test by listing the shared folder, and should now see the test_dir and test_file we created on the 'master' server.

Note that the 'slave' server(s) cannot create files at the 'root' of shared folder (e.g. /opt/sshfs). This is by design. However, they should have full access to everything below that level. If you add content to the shared folder /opt/sshfs_export on master server, don't forget to set correct ownership to allow full access by the slave server(s):

Alternatively, you can create /opt/sshfs also on the 'master' server and mount the SSHFS folder there using 127.0.0.1 as the server IP. If you do this and always access the shared folder via path /opt/sshfs, all new files created within will automatically have the correct ownership autossh:autossh.

To unmount the shared folder, use the following command:

Congratulations! You have successfully set up SSHFS and can now use the shared folder across all your servers.

Please share this post if you like it, and do not hesitate to write your comments or questions in the Disqus form below.


Next article: Check Your Server for Malware from SSH Attacks
Previous article: IPsec VPN Server Auto Setup with Libreswan
Return to Lin's Tech Blog Homepage

SSHFS (SSH File System) is a file system client used to mount and interact with directories and files located on a remote server or workstation. The client interacts with the remote file system via the SSH File Transfer Protocol (SFTP), a network protocol providing file access, file transfer, and file management functionality over any reliable data stream that was designed as an extension of the Secure Shell protocol (SSH) version 2.0. Further details at http://en.wikipedia.org/wiki/SSHFS

SSHFS provides the ability to mount WestGrid network drives or directories to the local desktop that supports the use of local file management tools to manage data between the local file system and any WestGrid file system. SSHFS is a mechanism that will support local editing of files without the need to download files to the local system. Simply open and edit your data using your local applications. SSHFS functions well for transferring small (>5GB data files) between the local file system and WestGrid file systems. Simultaneous transfer of many large files is inconsistent and performance is not as good as other tools like Globus Online.

Installation Instructions for Supported Operating Systems

MAC OS
Windows
Linux

Macports and SSHFS on MAC OS 10.6.8

Note (2015-04-03): Since this guide was written, graphical installers for OSXFUSE (a successor to MacFUSE) and SSHFS have become available from the FUSE for OS X site for Mac OS X 10.5 and later. You might like to use those instead of the more involved MacPorts procedure described below.

This guide is designed for MAC OS 10.6.8. Earlier or more current MAC OS versions may require different version of Macports and XCode in order for the installation to work.

Step 1

Note that in order to install and run MacPorts on Mac OS X, your system must have installations of XCode and Apple's Command Line Developer Tools. For detailed instructions on how to install these prerequisite tools and MACPORTS, please visit MacPorts official website.

Step 2

Download and install MacPorts. You should download the version that is compatible with your OS. Visit MacPorts official website and follow instruction in the section “Mac OS X Package (.pkg) Installer”

(2015-04-03: A step seems to be missing in the instructions here: sudo port install sshfs).

Step 3

Windows sshfs client

Once the installation is complete, you are ready to start using SSHFS to mount a remote file system.

% sshfs user@host:/path/to/remote /tmp/remotefs

Example Mount:

Local-iMac:~ sam$ mkdir RemoteHome
Local-iMac:~ sam$ sshfs sam@silo.westgrid.ca:/home/sam RemoteHome
sam@silo.westgrid.ca's password:

Now that the WestGrid file system has been successfully mounted to the local desktop, the terminal command line can be used to copy files between the local file system and the WestGrid remote file system

Local-iMac:~ sam$ cp /Users/sam/file1 /RemoteHome/file1

Step 4

File transfers between the local file system and the WestGrid remote file system can also be performed using MAC OS X file management tools.

Open Finder to locate the mounted drive. Notice 'RemoteHome' displays as a shortcut link to a network mounted drive. You can now copy data between the two file systems with ease.

DOKAN and SSHFS on Windows 7

Note (2016-02-20): The instructions below regarding the Dokan library and the download links for Dokan SSHFS are obsolete. There are up-to-date instructions for building the software at https://github.com/dokan-dev/dokan-sshfs, but , this is quite technical and requires experience with Microsoft Visual Studio.

Dokan is a support library for SSHFS that is required for installation. It serves as middleware that obviates the need to write a specific device driver. For more information on Dokan, visit http://dokan-dev.net/en/about/

This guide is designed for Windows 7. Other supported (not tested by WestGrid) version includes: Windows XP, 2003, Vista, 2008, 7 x86 and Windows 2003, Vista, 7, 2008R2 x64.n

Step 1

Download and install DOKAN Library. You should download the version that is compatible with your OS.

Step 2

Unzip the DOKAN SSHFS files to your local directory. Step 3 Run DokanSSHFS.exe file that was located in the ZIP package downloaded in Step 2.

Step 3

Run DokanSSHFS.exe file that was located in the ZIP package downloaded in Step 2.

Step 4

Setup an SSHFS connection to bugaboo.westgrid.ca. This tool can be used to setup an SSHFS connection to any WestGrid host. Performing this task will display a network drive (N:) available in windows explorer file manager.

Step 5

Installation should now be complete. Files can be transferred between the local file system or any network drive using the standard file management features of the windows explorer tool.

FUSE and SSHFS on Linux

This guide does not exhaust installation instructions for all distributions of the Linux operating system. You are encouraged to seek out current documentation for your specific distribution. For example, in Ubuntu Linux, simply perform an apt-get install sshfs for the SSHFS package; in Red Hat, perform a yum install sshfs.

If these packages are not available for your distribution of Linux, you can install from source. This guide will focus on how to install FUSE and SSHFS from source.

Features include:

  • Simple library API
  • Simple installation (no need to patch or recompile the kernel)
  • Secure implementation
  • Userspace - kernel interface is very efficient
  • Usable by non privileged users
  • Runs on Linux kernels 2.4.X and 2.6.X
  • Has proven very stable over time

Step 1

Installation: sshfs-fuse

Sshfs
  1. Download the latest stable FUSE tarball from SourceForge.net
  2. Unpack the archive:
    tar -zxvf fuse-2.X.X.tar.gz
  3. Configure FUSE for compilation:
    ./configure –disable-kernel-module --prefix=/usr/local
  4. Compile FUSE:
    make
  5. If the compilation completes successfully, enter
    make install
    to complete the installation of FUSE

Example:

Sshfs

Local-linux:~/Downloads$ wget http://downloads.sourceforge.net/project/fuse/fuse-2.X/2.9.2/fuse-2.9.2.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Ffuse%2Ffiles%2Ffuse-2.X%2F&ts=1363119109&use_mirror=iweb
Local-linux:~/Downloads$ tar –zxvf fuse-2.9.2
Local-linux:~/Downloads$ cd fuse-2.9.2
Local-linux:~/Downloads$ ./configure –disable-kernel-module –prefix=/usr
Local-linux:~/Downloads$ make
Local-linux:~/Downloads$ make install

Step 2

Windows Fuse Sshfs

Mount a FUSE Filesystem

Enter sshfs username@server:/directory /mountpoint to use FUSE to mount a directory on a remote server.

Note, that it's recommended to run it as user, not as root. For this to work the mountpoint must be owned by the user. If the username is different on the host you are connecting to, then use the 'username@host:' form. If you need to enter a password sshfs will ask for it (actually it just runs ssh which ask for the password if needed). You can also specify a directory after the ':'. The default is the /home directory.

Example:

sam@linux:~$ mkdir mountbugaboo

sam@linux:~$ sshfs sam@bugaboo.westgrid.ca:/home/sam /mountbugaboo
sam@linux:~$ cp localfile1 /mountbugaboo/*

Installation should now be complete. Files can be transferred between the local file system or any network file system using the standard file management features of the linux operating system including GUI file management tools.

Updates: 2015-04-03 - Added missing step to MacPorts-based installation and referenced graphical installer for OSXFUSE and SSHFS. 2016-02-20 - Provided a link to new Dokan SSHFS installation instructions.