Curious S.T.E.M Loving Fellow

Use local dev tools on remote files with SSHFS

November 13, 2020

I often have to work with virtual machines or remote hosts. To utilize my local development environment while doing so I configure SSH and SSHFS. Enabling the use of tools on the local host while working with files on the remote, with the security of ssh.

SSHFS (SSH filesystem) enables the mounting of a remote directory over a normal ssh connection to the local filesystem. Prior to installing, make sure SSH is setup with the appropriate keys.

  1. Download & Install FUSE for macOS
  2. Download & Install SSHFS

Mount remote filesystems

The following command mounts the remote directory to a specified mount point.

sshfs username@remotesystem:/remote/path/to/directory ~/mount/point

The rmount and rumount bash scripts facilitate convenient mount and unmounts using sshfs. To begin using the scripts.

  1. Create a folder named mounts in your user home directory, ~/mounts.
  2. Download the scripts and make them executable, chmod u+x <path-to-script>.

The functions reference host named in the local ~/.ssh/config file, configured with a key pair (without a password). See earlier blog post on the subject for reference.

Host ml
  HostName ec2-*.compute-1.amazonaws.com
  User ubuntu
  PreferredAuthentications publickey
  IdentitiesOnly yes
  IdentityFile ~/.ssh/aws
  Port 22

Executing rmount ml - will mount the entire filesystem to a local ml (~/mounts/ml) folder. A folder created by the function. The default “mounts” path, created earlier, can be changed by modifying the function. Executing rmount ml:/home/ec2-user mounts the ec2-user directory in ~/mounts/ml/. Running rumount ml, removes the ml folder and unmounts the remote filesystem.

With a remote filesystem mounted locally, local development tools can be used without having to download each file or having to remember to sync files. Its a secure tunnel to your remote filesystem where files behave almost as if they’re local.


I’m publishing this as part of 100 Days To Offload. You can learn more by visiting #100DaysToOffload.


References


T.J. Kolleh
Engineer with interests in the development & delivery of A.I. enhanced products. This site is a collection of thoughts about technology, and a way to keep track of research.
Built by (⚡tkolleh) 2018 - 2020, ፯ Number 7 Consulting LLC
Creative Commons License