Menu
I’m a Linux fanboy. Used to love Microsoft, now…not so much. Used to hate Mac, now…well, I love their hardware, and OSX sure has a pretty face.
The Win-sshfs application enables you to configure and use SSHFS connections on computers running Microsoft Windows. To use Win-sshfs, you must download and install the following components (some of these may be installed on your system already).NET Framework 4.0; Dokan Library. I used to use Macfusion on my old Macbook, but it failed on the new Mountain Lion system. The Macfusion keeps complaining 'Could not mount filesystem: Mount process has terminated unexpectedly'. I got the SSHFS worked via the command line as is mentioned in this post. First, download the sshfs binary and unzip.
Anyway, these days, I spend a ton of time with OSX, even though I prefer developing on a Linux Desktop in a VM. But there are times it would be nice to spin up a new VM and mess with its files using some tools installed on the OSX host.
Today I found out how.
Install SSHFS
We’re just going to use the same trick that is available to Linux users, but we have to jump through some hoops to get it on Mac.
Helio Tejedor’s article has a ton of detail about installation, but I found the most relevant bit is this:
The easy way to install SSHFS is navigate to http://osxfuse.github.io and download two files:
![How to download sshfs macbook pro How to download sshfs macbook pro](/uploads/1/2/6/8/126872181/551021135.png)
- OSXFUSE 2.7.3
- SSHFS 2.5.0
Do that, but just pick the latest two versions listing right on their homepage.
Manually test it out
Digital Ocean’s article is, like most Digital Ocean articles, excellent documentation. The section “Mounting the Remote File System” has a detailed explanation about how to mount remote drives using SSHFS. I just needed these two lines for my test VM (at IP address 192.168.56.101).
![Sshfs unmount mac Sshfs unmount mac](/uploads/1/2/6/8/126872181/143982070.png)
The observant reader will notice that:
- The
user
is the name of the SSH account that can connect to the box. - I am “cheating” by using the IP address for the folder name…
- …which may have unexpected results when my VM gets a new DHCP lease.
I’m good with all that. It works!
Script it
Mounting, unmounting, making directories…boring. I scripted this as
mountvm
, and now I have a simple one-liner to mount/unmount/etc. that mimics ssh
.Here’s the magic sauce, for your discerning palette.
Merry Christmas!
There’s a handy tool for Mac users that I rarely see getting use, theSSHFS filesystem. SSHFS is aFUSEfilesystem uses theSSH File Transfer Protocol(SFTP) as it’s backend. The short of it is that you can mount a remotedirectory on your local machine with nothing more than SSH access.
FUSE is the Filesystem in Userspace, a operating system extensionthat allows non-root users to create mountable filesystems. FUSE isavailable for most UNIX-like operating systems, including OS X.
Installation
The first step to using SSHFS is to installFUSE for OS X (There’s a prior versioncalled MacFUSE, you don’t want that). Once installed, reboot your Mac.
By itself, FUSE for OS X doesn’t do much, it provides the layer foruserspace filesystems, but no filesystems itself, sodownload (found on the FfOSX page) andinstall SSHFS as well.
Mounting
Now that you have SSHFS installed, you can create a local SFTP backedvolume with the
sshfs
command.First you need a directory that you can mount the filesystem on:
Then run
sshfs
:The first option is the remote path, it can contain a username as welli.e.
[email protected]:/var/www
. Because SSHFS uses SSH under thehood, your ~/.ssh/config
settings are honored. Whatever ssh*something*
does will apply to sshfs *something*:path
. You canalso leave of the path to the remote home directory i.e sshfsserver.example.com: ...
When you are done, you can unmount the filesystem with:
Or ejected it in the Finder.
Options
-o defer_permissions
is important! The default behavior is use thenormal system of checking UIDs for file access. Unless you have the same UIDon both your Mac and the remote system, this is probably not going towork. defer_permissions let’s the remote system handle permissionchecks, if you can access a file on the server, you will be to accessit locally. If you’re the kind of person who make sure that your UIDsare the same everywhere, then you need help, but you don’t needdefer_permissions
.-o volname=Server
sets the name that the volume will have in theFinder. Otherwise it’s called something like OSXFUSE Volume 0 (sshfs)Mount Location
How To Download Sshfs Mac Pro
Where you mount it matters as that’s where the drive icon willappear. In the above example, I create the local mount point in theDesktop folder, which makes the drive appear on the Desktop whenmounted. The downside of that, is then when the drive is not mounted,you have an empty folder that appear on the Desktop.
Another popular approach is to mount it in /Volumes, where OS Xtraditionally mounts drives.
The OS will automatically remove the directory when you unmount,you’ll need to create it each time, but you won’t need to clean it up.
Wherever you mount it, the drive icon will always appear in the Finderunder Devices -> Your Computer. And, of course, if you’re usingcommand line, the drive icon is pretty much a non-issue.
Download Sshfs Mac
Sharing with Others
By default, the file system is only visible to the person that mountedit. To allow other users to see it you can add
-o allow_other
to thecommand line. This can be a little dangerous when combined withdefer_permissions as everyone will have the permissions of theaccount that was used for the SSH connection. Use this option with care.Workflow
As I’ve previously written, myperfered workflow for uploading to servers is to use a combination ofMake/Rake and rsync. What I really like SSHFS for is browsing. Usingthe Finder I can open a folder and use the Quick Look feature to, say,search through a directory of images.
However, you can just as easily read and write files on the serverthrough SSHFS, allowing you to apply your favor desktop tools to theremote files.
Additional Filesystem
There are wide variety of filesystems for FUSE, but unfortunately,most of them have not been ported to OS X. My favorite, conceptuallyanyway, I haven’t used it, isPNGDrive, a file system thatautomatically hides data in PNG files usingSteganography
In terms of file systems that actually work under OS X, there’s alist here:
The most useful are probably:
fuse-ext2 which allowsyou to mount ext2, ext3, and ext4 devices and images on your Mac andNTFS-3G for NTFS.