Tutorial

How To Use SSHFS to Mount Remote File Systems Over SSH

Updated on April 27, 2022
authorauthor

Paul White and Alex Garnett

How To Use SSHFS to Mount Remote File Systems Over SSH

Introduction

Transferring files over an SSH connection, by using either SFTP or SCP, is a popular method of moving small amounts of data between servers. In some cases, however, it may be necessary to share entire directories, or entire filesystems, between two remote environments. While this can be accomplished by configuring an SMB or NFS mount, both of these require additional dependencies and can introduce security concerns or other overhead.

As an alternative, you can install SSHFS to mount a remote directory by using SSH alone. This has the significant advantage of requiring no additional configuration, and inheriting permissions from the SSH user on the remote system. SSHFS is particularly useful when you need to read from a large set of files interactively on an individual basis.

Prerequisites

  • Two Linux servers which are configured to allow SSH access between them. One of these can be a local machine rather than a cloud server. You can accomplish this by following our Initial Server Setup Guide, by connecting directly from one machine to the other.

Step 1 — Installing SSHFS

SSHFS is available for most Linux distributions. On Ubuntu, you can install it using apt.

First, use apt update to refresh your package sources:

  1. sudo apt update

Then, use apt install to install the sshfs package.

  1. sudo apt install sshfs

Note: SSHFS can be installed on Mac or Windows through the use of filesystem libraries called FUSE, which provide interoperability with Linux environments. They will use identical concepts and connection details to this tutorial, but may require you to use different configuration interfaces or install third-party libraries. This tutorial will cover SSHFS on Linux only, but you should be able to adapt these steps to Mac or Windows FUSE implementations.

You can install SSHFS for Windows from the project’s GitHub Repository.

You can install SSHFS for Mac from the macFUSE Project.

Step 2 — Mounting the Remote Filesystem

Whenever you are mounting a remote filesystem in a Linux environment, you first need an empty directory to mount it in. Most Linux environments include a directory called /mnt that you can create subdirectories within for this purpose.

Note: On Windows, remote filesystems are sometimes mounted with their own drive letter like G:, and on Mac, they are usually mounted in the /Volumes directory.

Create a subdirectory within /mnt called droplet using the mkdir command:

  1. sudo mkdir /mnt/droplet

You can now mount a remote directory using sshfs.

  1. sudo sshfs -o allow_other,default_permissions sammy@your_other_server:~/ /mnt/droplet

The options to this command behave as follows:

  • -o precedes miscellaneous mount options (this is the same as when running the mount command normally for non-SSH disk mounts). In this case, you are using allow_other to allow other users to have access to this mount (so that it behaves like a normal disk mount, as sshfs prevents this by default), and default_permissions (so that it otherwise uses regular filesystem permissions).
  • sammy@your_other_server:~/ provides the full path to the remote directory, including the remote username, sammy, the remote server, your_other_server, and the path, in this case ~/ for the remote user’s home directory. This uses the same syntax as SSH or SCP.
  • /mnt/droplet is the path to the local directory being used as a mount point.

If you receive a Connection reset by peer message, make sure that you have copied your SSH key to the remote system. sshfs uses an ordinary SSH connection in the background, and if it is your first time connecting to the remote system over SSH, you may be prompted to accept the remote host’s key fingerprint.

Output
The authenticity of host '164.90.133.64 (164.90.133.64)' can't be established. ED25519 key fingerprint is SHA256:05SYulMxeTDWFZtf3/ruDDm/3mmHkiTfAr+67FBC0+Q. This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

Note: If you need to mount a remote directory using SSHFS without requiring sudo permissions, you can create a user group called fuse on your local machine, by using sudo groupadd fuse, and then adding your local user to that group, by using sudo usermod -a -G fuse sammy.

You can use ls to list the files in the mounted directory to see if they match the contents of the remote directory:

  1. ls /mnt/droplet
Output
remote_file1 remote_file2

Now you can work with files on your remote server as if it were a physical device attached to your local machine. For instance, if you create a file in the /mnt/droplet directory, the file will appear on your virtual server. Likewise, you can copy files into or out of the /mnt/droplet folder and they will be uploaded to or from your remote server in the background.

It is important to note that the mount command only mounts a remote disk for your current session. If the virtual server or local machine is powered off or restarted, you will need to use the same process to mount it again.

If you no longer need this mount, you can unmount it with the umount command:

  1. sudo umount /mnt/droplet

In the last step, you’ll walk through an example of configuring a permanent mount.

Step 3 — Permanently Mounting the Remote Filesystem

As with other types of disk and network mounts, you can configure a permanent mount using SSHFS. To do this, you’ll need to add a configuration entry to a file named /etc/fstab, which handles Linux filesystem mounts at startup.

Using nano or your favorite text editor, open /etc/fstab:

  1. sudo nano /etc/fstab

At the end of the file, add an entry like this:

/etc/fstab
sammy@your_other_server:~/ /mnt/droplet fuse.sshfs noauto,x-systemd.automount,_netdev,reconnect,identityfile=/home/sammy/.ssh/id_rsa,allow_other,default_permissions 0 0

Permanent mounts often require a number of different options like this to ensure they behave as expected. They work as follows:

  • sammy@your_other_server:~/ is the remote path again, just as before.
  • /mnt/droplet is the local path again.
  • fuse.sshfs specifies the driver being used to mount this remote directory.
  • noauto,x-systemd.automount,_netdev,reconnect are a set of options that work together to ensure that permanent mounts to network drives behave gracefully in case the network connection drops from the local machine or the remote machine.
  • identityfile=/home/sammy/.ssh/id_rsa specifies a path to a local SSH key so that the remote directory can be mounted automatically. Note that this example assumes that both your local and your remote username are sammy – this refers to the local path. It is necessary to specify this because /etc/fstab effectively runs as root, and would not otherwise know which username’s SSH configurations to check for a key that is trusted by the remote server.
  • allow_other,default_permissions use the same permissions from the mount command above.
  • 0 0 signifies that the remote filesystem should never be dumped or validated by the local machine in case of errors. These options may be different when mounting a local disk.

Save and close the file. If you are using nano, press Ctrl+X, then when prompted, Y and then ENTER. You can then test the /etc/fstab configuration by restarting your local machine, for example by using sudo reboot now, and verifying that the mount is recreated automatically.

It should be noted that permanent SSHFS mounts are not necessarily popular. The nature of SSH connections and SSHFS means that it is usually better suited to temporary, one-off solutions, when you don’t need to commit to an SMB or NFS mount which can be configured with greater redundancy and other options. That said, SSHFS is very flexible, and more importantly, acts as a full-fledged filesystem driver, which allows you to configure it in /etc/fstab like any other disk mount and use it as much as needed. Be careful that you do not accidentally expose more of the remote filesystem over SSH than you intend.

Conclusion

In this tutorial, you configured an SSHFS mount from one Linux environment to another. Although it is not the most scalable or performant solution for a production deployment, SSHFS can be very useful with minimal configuration.

Next, you may want to learn about working with object storage which can be mounted concurrently across multiple servers.

We’ve made it super easy to add SSH Keys to your new or existing DigitalOcean virtual machines.

Learn more here

About the authors
Default avatar
Paul White

author


Default avatar

Senior DevOps Technical Writer


Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
59 Comments
Leave a comment...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Are there any good (non-abandoned) GUI for mounting remote file systems over SSH on OS X, from a menubar icon?

Panic Transmit does it very well, but it would be great to have a free alternative that would simply runs the command shown in this article in the background to mount a file system.

alexdo
Site Moderator
Site Moderator badge
January 31, 2024

Heya,

That’s the thing with open-source projects, sometimes they can be left to collect dust. I believe the process is relatively simple but a GUI is never a bad idea to handle the process for you.

Regards

Not a new way , and particularly sucks given the slow speed !!! I think you must enable some options for sync reads and write .

for 2Mbit connection it is fast enough

Using a lighter encryption algorythm makes it much faster, I recommend this one if you’re not worried about security too much

-o ssh_command="ssh -Cc arcfour256"
-o ssh_command="ssh -Cc arcfour256"

doesnt work for me:

read: Connection reset by peer

for OSX , SSHFS GUI hosted on code.google.com works fine … else even MacFusion used to work … but the recent version seems not to work on at-least Mavericks .

For SFTP , think this does most of the job, CyberDuck the best option .

you are confusing things. sftp is completely different program with different ideas behind. you can’t run emacs on your computer in order to edit remote file with sftp, while with sshfs you can.

If you don’t want to add SSHFS settings in /etc and prefer a GUI and per-user configurable accesses, you should check Qasim (contributions are welcome) : http://glenux.github.io/qasim/

Failed on Mavericks. After the sshfs command was executed locally, the password was continually rejected.

alexdo
Site Moderator
Site Moderator badge
January 31, 2024

You can ensure that the password is correct and if possible to use ssh keys instead.

Regards

if you use KDE, launch dolphin and just type as path “fish://myserver.com/mypath”, it will ask your username and password and that’s it. It cannot be simpler than that

Andrew SB
DigitalOcean Employee
DigitalOcean Employee badge
June 4, 2014

@ruben: Thanks for the tip! You can do the same in GNOME and other desktops that use nautilus as their file manager using:

<pre> nautilus sftp://root@162.243.197.120 </pre>

This is some great information, and I’m glad I read through all the comments. Now that I see I can use nautilus to open files, I’m wondering when you would mount a file system instead… file transfer faster?

I have just tried to do exactly what’s said here but all I get is “read: connection reset by peer” EVERY single time. Why isn’t it working for me??

Kamal Nasser
DigitalOcean Employee
DigitalOcean Employee badge
July 19, 2014

@timothy_holt123: Try passing -o sshfs_debug to sshfs to make it print debugging information. Does it output any errors?

@timothy_holt123:_ I just got this because I was using sudo and it wasn’t passing my SSH_AGENT_PID to the sudo environment. So I just dropped the sudo, since it was overkill. You could also pass the environment to sudo with -E option.

This comment has been deleted

    Thanks a million to the author of this excellent article. It was quite helpful for me, because I was looking for a long time for a solution to the problem of mounting remote files to my laptop, which is easier than NFS or OpenAFS.

    Everything works just fine. I do not agree with the previous comment that it is slow. I believe that if your connection allows you work comfortably with ssh then sshfs will be fast enough.

    A couple of comments: author is calling all commands using sudo. I think it may be not very convenient to add every program, which you want to use to edit mounted files, to sudoers. So I have just changed the owner of the directory /mnt/droplet to my username and group and can do everything directly, without sudo.

    And I decided that it is better to call the directory /mnt/sshfs/droplet in order to remember, for which program this mountpoint is created. So, in case I use other programs for mounting in future, I can create for them a different mount point, for example, /mnt/openafs/droplet

    This comment has been deleted

      I reckon this is the best option.

      sshfs -o IdentityFile=~/.ssh/id_rsa,auto_cache,reconnect,defer_permissions,negative_vncache,volname=Deploy root@linw.live:/opt/wildfly-8.1.0.Final/standalone/deployments ~/Deploy
      

      I like the folder ~/Deploy could be anything you want though, just change the volume name as well.

      How can I make this work while root access to ssh is rejected? I’d assume I could use user@$REMOTE_SERVER , bit would I have to use a script to connect and su - ? I’ve added that user to the sudoers file, but still does not want to work?

      Kamal Nasser
      DigitalOcean Employee
      DigitalOcean Employee badge
      October 11, 2014

      Try passing -o sftp_server="/usr/bin/sudo /usr/lib/openssh/sftp-server" to sshfs:

      sudo sshfs -o IdentityFile=~/.ssh/id_rsa,sftp_server="/usr/bin/sudo /usr/lib/openssh/sftp-server" root@xxx.xxx.xxx.xxx:/ /mnt/droplet
      

      I am able to mount my servers dev site docroot just fine, but locally I cannot see any hidden files like .htaccess, .git, .gitignore, etc. Any else have this issue and/or a solution?

      Thanks for the great tutorial!

      sshfs works very well for mounting my VMs across my LAN, don’t like it for remote mounts, seems pretty unstable in those cases. The windows client is particularly bad, I only trust it to mount VMs shares on the same pc.

      The only problem I have on the mounted drives is that I can’t commit with git.

      alexdo
      Site Moderator
      Site Moderator badge
      January 31, 2024

      Heya,

      For remote servers like buckets you can use s3fs to mount the Space on your local server/droplet.

      https://simplebackups.com/blog/mounting-digitalocean-spaces-and-access-bucket-from-droplet/

      Hope that this helps!

      I followed these instructions exactly and still had connection problems.

      I was trying to connect my Ubuntu 14.04 laptop to an Ubuntu 14.04 droplet that I have setup SSH access without password and without a password for the key.

      I was getting “permission denied” at the mount folder, even with sudo.

      What fixed it is adding my account to the fuse group:

      sudo gpasswd -a USERNAME fuse
      

      And also editing /etc/fuse.conf on my laptop and enabling a flag by uncommenting the second line here:

      # Allow non-root users to specify the allow_other or allow_root mount options.
      user_allow_other
      

      Lastly the mount command needs to be modified with an extra option:

      sudo sshfs -o allow_other -o IdentityFile=~/.ssh/id_rsa root@xxx.xxx.xxx.xxx:/ /mnt/droplet
      

      @SamiF super helpful! Thank you so much.

      It works after I follow this…why is this not posted more prominently?? Thanks.

      I guess the article is written for a certain use case, the more common one. Because of the special circumstance of not using a password for both the key and server, a special workaround is needed. I agree the article should be amended but for these cases the comments work wonders! @aschuss @jayliu50

      That is good, it works.

      I’ve got it working on OS X Yosemite.

      I think this article needs some rewriting/renovation. It’s going to directly conflict with a more fundamental tutorial that disables root ssh login. Plus there are permission problems. Even when I got it showing remote files they were read-only. (finally I fixed this!)

      The most useful advice I can give to someone would be: First attempt to map user <--> user, instead of root <--> root.

      mkdir ~/RemoteFS/droplet
      sshfs  pi@46.101.38.186:/home/pi  ~/RemoteFS/droplet
      

      Permissions are important here. For example if you sudo the mkdir it will produced a read-only problem.

      sshfs seems to be smart enough to look for that URL in its ~/.ssh/known_hosts and use the appropriate key for that ip, so no need for that extra -o IdentityFile=~/.ssh/ocean_rsa option.

      Also no need for -o allow_other.

      I think root <--> root may be trickier, but I think the majority of users shouldn’t be doing this anyway.

      A few final points, the article doesn’t help the reader decide what is the best choice for remote file transfer. There are other articles, e.g.

      How To Use SFTP to Securely Transfer Files with a Remote Server How To Use Filezilla to Transfer and Manage Files Securely on your VPS

      But no clear advice for how to choose which approach to go with. As far as I can see sshfs wins hands down. OSX sees the remote FS as native. So the remoteFS will be transparent to any OSX app, including Finder.

      Finally, it is possible to use homebrew to install OSXFuse and sshfs. The article should point this out and help the reader decide which path to take. (I would have chosen homebrew retrospectively as it keeps things tidy).

      I was receiving an error “Connection reset by peer” so used the following command in my terminal

      sshfs -o debug root@xxx.xxx.xxx.xxx:/ /home/joe/DigitalOcean/
      

      where xxx.xxx.xxx.xxx is my Digital Ocean IP Address for the droplet followed by the /home/joe/DigitialOcean/ which is the location of my local folder for mounting.

      It brought back a warning message and instructions on resetting the key

      remove with: ssh-keygen -f "/home/joe/.ssh/known_hosts" -R xxx.xxx.xxx.xxx
      

      i guess is not working on os x yosemite

      The sshfs bin is not bundled with osxfuse base, you need the additional package located here: github.com/osxfuse/sshfs/releases

      The article mentions an older win-sshfs that doesn’t seem to be developed anymore. The fork here supports pageant and more features (and IS under development it seems): https://github.com/dimov-cz/win-sshfs

      alexdo
      Site Moderator
      Site Moderator badge
      February 12, 2024

      I believe this repository should also work fine:

      https://github.com/winfsp/sshfs-win

      Regards

      Is there a way to disable directory be mounted inside? For example when you sync a folder with .git and you run git status it could take a long time to return. I would like to exclude this .git directory inside the mount if possible for sshfs.

      I tried using

      sudo sshfs root@xxx.xxx.xxx.xxx:/ /mnt/droplet

      as stated above. The data from the the remote server got completely wiped and I do not have permission to the mounted folder. I was able to log in as root to access the mounted folder but the data isn’t there! Please could anybody help me as to what I could do?

      alexdo
      Site Moderator
      Site Moderator badge
      February 7, 2024

      Heya,

      I will recommend you to perform the mount again and make sure you use the correct options/arguments one more time

      Regards

      on windows i got this to work using Fissh, which is a fork of the win-sshfs project. It uses doken 0.6 which it includes. There is no need to replace any files - everything needed is in the download.

      You must set the compatibility of the doken installer to windows 7 (if you are using win 8/10). Uninstalling doken fully before installing fissh is hard - the doken uninstaller misses entries in the registry.

      https://github.com/tuiSSE/win-sshfs my download was from this repo https://github.com/dimov-cz/win-sshfs/

      I hopefully fissh will be updated to use doken 1.0 which is nearly finished

      all works when other users are allowed. Hope this saves others time and heartache :)

      One note - on OSX I had to use an absolute path to my keyfile when running with sudo.

      IdentityFile=~/.ssh/id_rsa
      

      Would try to pull root’s ssh key, which didn’t exist

      IdentityFile=/Users/myuser/.ssh/id_rsa
      

      Would pull the one I wanted.

      alexdo
      Site Moderator
      Site Moderator badge
      February 7, 2024

      Heya,

      Thanks for sharing this! Yes, the correct path on OSX is /Users/$user/.ssh/im_rsa

      Regards

      defer_permissions should be default_permissions!

      alexdo
      Site Moderator
      Site Moderator badge
      February 7, 2024

      Thanks for bringing this!

      The article has been updated to match the new syntax.

      Regards

      shouldn’t it be default_permissions instead of defer_permissions?

      alexdo
      Site Moderator
      Site Moderator badge
      January 31, 2024

      Yes, this has been corrected in the article, thanks!

      Regards

      Perhaps there’s a typo in the article about the defer_permissions option, maybe it should be default_permissions, beacuse it threw an error on my system (Ubuntu 16.04) and I did a search about it finding this on askubuntu http://askubuntu.com/questions/780705/fuse-unknown-option-defer-permissions.

      alexdo
      Site Moderator
      Site Moderator badge
      February 7, 2024

      I believe this is the old syntax, it’s been corrected in the article so the steps should work fine now.

      Regards

      The direct download link (https://win-sshfs.googlecode.com/files/win-sshfs-0.0.1.5-setup.exe) for windows throws a 404 page.

      Any update or alternative link there?

      https://code.google.com/archive/p/win-sshfs/downloads

      thats the updated link from google since they changed domain name

      alexdo
      Site Moderator
      Site Moderator badge
      February 7, 2024

      Heya,

      I believe you can also get it from the official repo:

      https://github.com/winfsp/sshfs-win

      Regards

      Hi,

      Thanks for the useful tutorial. I’m working on a macOS Sierra v 10.12.13, and I’ve got 3 different Linux based servers I want to mount. I can manually mount them using my ssh keys as suggested. I’ve created an /etc/fstab file and added the following lines:

      sshfs#je714@host1:/work/je714/ /mnt/HPC
      sshfs#je714@host1:/box/je714/ /mnt/box
      sshfs#je714@host2:/ /mnt/titanx2
      

      And made sure that the directories do exist under the /mnt/ directory. But when I reboot my machine, nothing shows up in the folders. Does anyone know if using /etc/fstab needs some extra action to work on OSX?

      Thanks,

      Juan

      Have you found any solution for that? I have the same issue.

      To allow the client to access symlinks on the host use -o follow_symlinks.

      Example: sudo sshfs -o allow_other,default_permissions,follow_symlinks,IdentityFile= …

      alexdo
      Site Moderator
      Site Moderator badge
      January 31, 2024

      Heya,

      Thanks for sharing this with the community! The command can also be added to fstab to automatically mount it after each reboot.

      Regards

      sudo sshfs -o allow_other,“defer_permissions” root@xxx.xxx.xxx.xxx:/ /mnt/droplet change to sudo sshfs -o allow_other,“default_permissions” root@xxx.xxx.xxx.xxx:/ /mnt/droplet

      thank you very much. Best Regards Alexandre

      alexdo
      Site Moderator
      Site Moderator badge
      January 31, 2024

      Thanks for bringing this!

      The article has been updated to match the new syntax.

      Regards

      Using ‘defer_permissions’ gives an unknown option error in Raspberry-pi.

      sshfs man pages do not list it as an option.

      Using ‘default_permissions’ works for me. So maybe this is a typo.

      Others wounded by this typo: https://askubuntu.com/questions/780705/fuse-unknown-option-defer-permissions

      alexdo
      Site Moderator
      Site Moderator badge
      January 31, 2024

      I believe this option wont be available on the Raspberry-Pi so a good call to use the default_permission command. May I ask if you’ve mounted the droplet to your raspberry or you’re using different setup here.

      Regards

      Great article, but the command sudo sshfs -o allow_other,defer_permissions root@xxx.xxx.xxx.xxx:/ /mnt/droplet is incorrect.

      defer should be default! sudo sshfs -o allow_other,default_permissions root@xxx.xxx.xxx.xxx:/ /mnt/droplet

      alexdo
      Site Moderator
      Site Moderator badge
      January 31, 2024

      Heya,

      This has been updated to prevent issues with the different syntax.

      Regards

      defer_permissions to

      default_permissions
      

      defer_permission is deprecated

      alexdo
      Site Moderator
      Site Moderator badge
      January 31, 2024

      Yes, that is correct. I believe this has been edited correctly already.

      Regards

      Did this recently stop working for others with an error “connection reset by peer”.

      I’m a beginner and struggling. .This has been working for a few months … the only thing different is that I’m in a different location…but it has work in different locations before.

      If i turn on debug option in sshfs I get : ssh: Could not resolve hostname xxx.xxx.xxx.xxx: Name or service not known.

      alexdo
      Site Moderator
      Site Moderator badge
      February 7, 2024

      Have you made changes to the DNS? Another approach here will be to use the IP address instead of the hostname just for testing.

      You can also ensure that the remote server is online.

      Regards

      Ok so I’m kind of new at this. I’m trying to mount to a remote VPN. I’m on OSx 10.12.16 and when I run sshfs -V I get:

      SSHFS version 2.5 (OSXFUSE SSHFS 2.5.0) OSXFUSE 3.7.1 FUSE library version: 2.9.7 fuse: no mount point

      I can use regular ssh to connect to the VPN without any problems. When I try to mount though, I get this:

      sshfs -o defer_permissions,volname=hockey,compression=yes [username]@xxx.xxx.xxx.xxx:/[VPN path] /mnt/droplet

      mount_osxfuse: failed to mount /mnt/droplet@/dev/osxfuse0: Operation not permitted

      Any help would be appreciated.

      alexdo
      Site Moderator
      Site Moderator badge
      February 7, 2024

      Heya,

      You can try to mount the point with a sudo or with root username. You can also check if the mount point is not already in use for example if you’re already in the directory you have created for the mount.

      Hope that this helps!

      My use case is Linux to Linux. To get the mount to survive a reboot, I found I couldn’t use /etc/fstab. Instead, I put this in /etc/rc.local :

      sshfs -o allow_other,IdentityFile=~/.ssh/id_ecdsa root@x.x.x.x:/mnt/myremotedropletfilesystem

      I then found it was hanging on reboots, power cycles and power off/ons. To fix this , I created killsshfs.conf in /etc/init:

      description “pkill sshfs” start on deconfiguring-networking console log task

      exec /usr/bin/pkill sshfs

      The permissions for killsshfs.conf are -rw-r–r–

      Hope this helps someone. It took me a whole day to figure this out.

      alexdo
      Site Moderator
      Site Moderator badge
      February 7, 2024

      Thanks for sharing this! I believe other users can run into the same situation and this can help them!

      On my mac there is no file called fstab under /etc folder. But there is is fstab file under /etc folder on my Ubuntu machine. I was trying permanently mount a folder from my Ubuntu to my Mac.

      On my mac I tried to create a fstab file under /etc and did the same thing as instructions said but it didnot work

      alexdo
      Site Moderator
      Site Moderator badge
      January 31, 2024

      Yes, I believe the default file has been removed, but the fstab functionality has not been removed, so you can still use it.

      You can share the exact command that you’ve set in the fstab and we can check it for you.

      Regards

      I think defer_permissions should be default_permissions? Please see https://askubuntu.com/questions/780705/fuse-unknown-option-defer-permissions

      alexdo
      Site Moderator
      Site Moderator badge
      January 31, 2024

      Yes that is correct, the article has also been update with the new syntax in order to prevent errors.

      Regards

      How do you permanently mount a location which needs a key file?

      alexdo
      Site Moderator
      Site Moderator badge
      January 31, 2024

      You can use the fstab and automatically mount the location when the droplet boots and to mount it using ssh key you can the IdentityFile option - IdentityFile=/home/tux/.ssh/id_rsa

      Hope that this helps!

      KFSys
      Site Moderator
      Site Moderator badge
      October 22, 2024

      To permanently mount the remote location, you’ll need to modify /etc/fstab.

      1. Open /etc/fstab in your preferred text editor:
      sudo nano /etc/fstab
      
      1. Add an entry for your mount in the following format:
      sshfs#username@remote_host:/remote/path /local/mountpoint fuse.sshfs _netdev,IdentityFile=/home/username/.ssh/id_rsa,allow_other 0 0
      
      -   **`username@remote_host:/remote/path`**: Replace with your remote server’s user, hostname/IP, and the remote directory you want to mount.
      -   **`/local/mountpoint`**: The directory on your local machine where the remote folder will be mounted.
      -   **`IdentityFile=/home/username/.ssh/id_rsa`**: Specifies the SSH private key to use for authentication.
      -   **`allow_other`**: Allows other users on the system to access the mounted directory (optional).
      -   **`_netdev`**: Ensures that the network is available before attempting to mount the location.
      
      Example:
      
      sshfs#user@192.168.1.10:/var/www /mnt/remote_web fuse.sshfs _netdev,IdentityFile=/home/user/.ssh/id_rsa,allow_other 0 0
      

      Mount the Filesystem

      Once the /etc/fstab entry is added, test the mount by running:

      sudo mount -a
      

      This command checks all /etc/fstab entries and attempts to mount them.

      Auto-mount at Boot

      By configuring /etc/fstab with the _netdev option, the mount will automatically be available after a reboot.

      Troubleshooting

      • Ensure the key file has the correct permissions:
      chmod 600 ~/.ssh/id_rsa
      
      • If SSH authentication fails, check the remote server’s authorized_keys file and ensure the SSH key is added correctly.

      With this setup, the location will be mounted automatically at boot using the key file for authentication.

      Unfortunately the tutorial didn’t work for me. Ultimately I just added this command to my .bashrc so I can listen to music from my DO server anytime I start a terminal and cmus. sshfs user@host.com:/home/user/Music /home/user/Music

      Attention: in Linux the mounting does not work like this, second line is the correct version sudo sshfs -o allow_other,defer_permissions,IdentityFile=~/.ssh/id_rsa root@xxx.xxx.xxx.xxx:/ /mnt/droplet sudo sshfs -o allow_other,default_permissions,IdentityFile=/home/$USER/.ssh/id_rsa root@xxx.xxx.xxx.xxx:/ /mnt/droplet

      defer_permissions has to be default_permissions. key-file has to be an absolute path

      alexdo
      Site Moderator
      Site Moderator badge
      January 31, 2024

      Hello,

      This has already been changed in the article. Thanks for bringing it up to the community!

      Regards

      Attention: in Linux the mounting does not work like this, second line is the correct version sudo sshfs -o allow_other,defer_permissions,IdentityFile=~/.ssh/id_rsa root@xxx.xxx.xxx.xxx:/ /mnt/droplet sudo sshfs -o allow_other,default_permissions,IdentityFile=/home/$USER/.ssh/id_rsa root@xxx.xxx.xxx.xxx:/ /mnt/droplet

      defer_permissions has to be default_permissions. key-file has to be an absolute path

      alexdo
      Site Moderator
      Site Moderator badge
      January 31, 2024

      Thanks for mentioning this!

      Yes the new syntax is default_permissions and this has already been updated in the article to prevent errors during configuration.

      Is there any i/o perf benchmark available that I can refer too? I would like to evaluate it for fast r/w operation on remote location.

      alexdo
      Site Moderator
      Site Moderator badge
      February 7, 2024

      Heya,

      I believe there is no official tool to test this at the moment, but for example you can use the fio package to test the speed. Have in mind that the results from the test can not be considered as 100% legit test, but can be used as a proximate reference point on which you can take into consideration when designing your site/application.

      Hope that this helps!

      Thanks a lor! Danilo

      One problem with this is that the mounted fs does not update when the files change on the server.

      Main cases it happens is: change git branch, run some command which does a codemod.

      Facebook used to have open sourced a plugin in atom editor + a service to be installed on the remote dev box which kept track of changes. However, they aren’t really committed to do any good in the world and removed the plugin!!! https://discuss.atom.io/t/impact-of-nuclide-extension-being-removed/61242

      I would really like if there is a solution out there?

      Hi ! Amazing tutorial, but I have a problem. It was mounted ok, I could write and create new file from client and saw from host. But, I couldn’t list files or directories (ls ) from client. Neither create file in some folder from this mounted directory.

      The same happened to me using nfs.

      PD: My volumen shared size is 1TB

      Best Regards !

      alexdo
      Site Moderator
      Site Moderator badge
      February 7, 2024

      Heya,

      Have you tried using different client and if so does it make any difference? You can try using PuTTY or simple command line client like terminal.

      Regards

      TIP: On MacOSX I had to sudo chown as ${USER} to get this to mount otherwise I got mount_osxfuse: failed to mount: Operation not permitted.

      alexdo
      Site Moderator
      Site Moderator badge
      January 31, 2024

      Heya,

      Thanks for bringing this! Yes, on MacOS it is likely to need sudo or root permissions in order to setup the sshfs mount point.

      Regards

      Under: Mounting the Remote File System with the syntax: sudo sshfs -o allow_other,defer_permissions root@xxx.xxx.xxx.xxx:/ /mnt/droplet

      The defer_permissions is incorrect, and should be default_permissions Please update and fix. <3

      Bobby Iliev
      Site Moderator
      Site Moderator badge
      March 22, 2020

      Thank you for the feedback!

      I can see that this has been updated and it should be working as expected.

      Does anyone have any suggestions on speeding this up or an alternative solution? Sometimes sublime doesn’t load newly created files in the sidebar until you reopen it. Also, if you open your laptop and are no longer connected to the network, the computer just hangs up for a few minutes until fuse decides to catch up and realize the mount should be disconnected.

      alexdo
      Site Moderator
      Site Moderator badge
      February 7, 2024

      Heya,

      I like Sublime but have not used it with remote development. My guess here will be to test with different graphic editors like Visual Studio Code or similar.

      Regards

      Guys i’ve came out with a very handy tool to ease the use of sshfs, is a console one but it also use zenity for gui inputs.

      https://github.com/lemyskaman/kmountssh

      alexdo
      Site Moderator
      Site Moderator badge
      January 31, 2024

      Hello,

      Thanks for sharing this with the community! I will make sure to check it out and test it!

      Regards

      SSH key pair is the only available method, there has to be a way to do this on Windows…

      alexdo
      Site Moderator
      Site Moderator badge
      January 31, 2024

      So since using nonstandard ports is extremely useful in protecting an ssh server, you need to add a -p #### after sshfs if you use something other than 22.

      Hi! How should I rewrite the line in fstab to account for the non-standard port?

      sammy@your_other_server:~/ /mnt/droplet fuse.sshfs noauto,x-systemd.automount,_netdev,reconnect,identityfile=/home/sammy/.ssh/id_rsa,allow_other,default_permissions 0 0

      Thank you!

      Try DigitalOcean for free

      Click below to sign up and get $200 of credit to try our products over 60 days!

      Sign up

      Join the Tech Talk
      Success! Thank you! Please check your email for further details.

      Please complete your information!

      Become a contributor for community

      Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

      DigitalOcean Documentation

      Full documentation for every DigitalOcean product.

      Resources for startups and SMBs

      The Wave has everything you need to know about building a business, from raising funding to marketing your product.

      Get our newsletter

      Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

      New accounts only. By submitting your email you agree to our Privacy Policy

      The developer cloud

      Scale up as you grow — whether you're running one virtual machine or ten thousand.

      Get started for free

      Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

      *This promotional offer applies to new accounts only.