Thursday, November 15, 2012

SSHFS on OSX. Mount SSH/SFTP shares on the Mac.

For over 10 years, I wish Apple implemented something like this:



Command-K. Connect to Sever.

Oh, I wish for the ability to natively mount SFTP/SSH shares as volumes in the operating system. You can already do it with AFP, NFS, CIF,WebDAV, and even FTP. You can do this in many Linux distributions and I actually use it quite a bit in Ubuntu. If Only OSX did this natively!

Sure, there applications like Fetch, Cyberduck, Fillezilla and YummyFTP but it is not the same as a native mounted volume.

With native mounted volumes, you can treat them in any applications including the console and you are not restricted by the limitations of a FTP client. You can open files directly without having to upload/download as you do with as standalone FTP app.

For several years, the MacFuse/MacFusion project has been on-n-off with virtually no support for Lion on.

Fuse OSX (OSXFuse) and SSHFS projects have taken up the slack. They are the successor to the abandoned MacFuse project. Link: http://osxfuse.github.com/
It may not be easy as a point-n-click nature but you can mount SSH/SFTP shares in Mountain Lion via the console. (Note: MacFusion GUI works but only with SSH keys).

1) First, install the OSXFuse/SSHFS library/app.
2) Reboot.
3) Make a mount point directory by making an empty directory. Either in the /tmp/ or /Volumes/

mkdir /path/[local_dir]/

4) Then run sshfs
sshfs user@host:/[remote_dir] /path/[local_dir] -ocache=no -onolocalcaches -ovolname=[local_dir]

You will then be prompted to enter your SSH password. You can skip passwords if you have your SSH keys set-up.

Here is an example where I make a mount a volume and call it ssh. I make the mount point in my /tmp
 mkdir /tmp/ssh  
 sshfs root@172.16.1.57:/ /tmp/ssh -ocache=no -onolocalcaches -ovolname=ssh  

Voila. The mount point is now a visibile volume I can access. It should show up on the Desktop as a network share. Here, I have full access to one of my PogoPlugs running ArchLinux


When finish, you can then umount and remove the mount point.

 umount -f /tmp/ssh
 rmdir /tmp/ssh


Now,  you don't necessarily have to make a mkdir mount point if it already exists. For example, if you make a mount point in /tmp/ like I shown above. With an existing empty mount dir, you can skip step 3 and just go straight to the sshfs command.

Your volume can be named whatever you want and you can mount it in any directory path you choose.
Call your mount point, "MyMountPoint" for all I care.

I prefer to make mounts in the /tmp or /Volumes/ paths for consistency.


There you have it. Quite simple and now you can access SSH/SFTP shares like other file sharing protocols.

Now if the new VP of OSX engineering, Craig Federighi, ever reads this blog, please implement SFTP into the command-K Finder.

Link: http://osxfuse.github.com/

1 comment: