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.
The following command mounts the remote directory to a specified mount point.
sshfs username@remotesystem:/remote/path/to/directory ~/mount/point
- Create a folder named mounts in your user home directory,
- 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
rmount ml - will mount the entire filesystem to a local
~/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
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.