How to mount a remote file system over ssh
The following post describes how to mount a remote file system over ssh on Mac OS X 10.9.2. With minor modifications, the same thing can be achieved on other platforms.
Background
I recently needed to manipulate a sqlite database on a virtual machine and my gui tool lacked the ability to tunnel over ssh.
Enter sshfs: Secure SHell FileSystem – 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 using just a secure shell login on the remote computer.
In the example below, I’m mounting a file system from a VirtualBox virtual machine controlled by vagrant (which happens to use port 2200 on the loopback address 127.0.0.1).
Prerequisites
- Mac OS X 10.9.2
- Homebrew
Installation
Install sshfs via Homebrew:
|
|
Follow instructions for osxfuse (refer to brew info osxfuse):
|
|
The remote file system is now mounted at /Volumes/mount_name and one can access files via Mac OS applications and/or the Finder.
Unmount
Close any open files and cd out of the mount_name directory before executing the following command to unmount the remote file system:
|
|
Summary
sshfs is a lightweight solution to efficiently mount a remote file system for local access.