Skip to content

Instantly share code, notes, and snippets.

@vordan
Created September 24, 2017 18:47
Show Gist options
  • Save vordan/14dca8e7138ff5a815b4a94fff5ea325 to your computer and use it in GitHub Desktop.
Save vordan/14dca8e7138ff5a815b4a94fff5ea325 to your computer and use it in GitHub Desktop.
How To Use SSHFS to Mount Remote File Systems Over SSH
Installing sshfs
===================
SSHFS is Linux based software that needs to be installed on your local computer.
On Ubuntu and Debian based systems it can be installed through apt-get.
sudo apt-get install sshfs
Mounting the Remote File System
===============================
sudo mkdir /mnt/droplet <--replace "droplet" whatever you prefer
sudo sshfs -o allow_other,defer_permissions [email protected]:/ /mnt/droplet
If your droplet is configured for login via ssh key authorization, you will need to tell sshfs to use
your public keys with the following command.
You will be asked to enter the passphrase you used during the creation of your keys with ssh-keygen.
sudo sshfs -o allow_other,defer_permissions,IdentityFile=~/.ssh/id_rsa [email protected]:/ /mnt/droplet
Unmounting the Remote File System
=================================
sudo umount /mnt/droplet
Permanently Mounting the Remote File System
===========================================
SSHFS also allows for setting up permanent mount points to remote file systems.
This would set a mount point that would persist through restarts of both your local machine and droplets.
In order to set up a permanent mount point, we will need to edit the /etc/fstab file on the local machine to automatically
mount the file system each time the system is booted.
First we need to edit the /etc/fstab file with a text editor.
Scroll to the bottom of the file and add the following entry
sshfs#[email protected]:/ /mnt/droplet
Save the changes to /etc/fstab and reboot if necessary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment