Archive for the ‘Mac OS’ Category
Mounting Linux Volumes with SFTP in Mac OS
Mounting Linux directories remotely using SFTP is incredibly handy. It allows you to easily move files back and forth between systems, and easily test and develop websites and other hosted services. It used to be super-easy to setup, MacFuse was the de facto way to install things, but has recently had some growing pains when it comes to being supported in Mac OS Lion. It is no longer actively maintained by Google and just doesn’t work very well.
There’s been a number of groups that have picked up the gauntlet and continued support for MacFuse, but instructions for installation by the end user aren’t really clear. MacFuse is designed to be a module to build file systems on top of so it’s generally not documented too well.
After a little bit of fumbling, I’ve found a procedure that works.
- Install everything with MacPorts – You’ll need MacPorts installed for this to work, the open-source package management system for Mac OS.
We’ll be installing Fuse4X, which is a continued effort to develop on the MacFuse codebase.
sudo port install fuse4x sshfs
- Make a mount point and test it out – Go ahead and create a directory in your home directory, and try to create a sshfs mount.
mkdir ~/remote sshfs andrew@someserver.com:/home/andrew/ ~/remote -oauto_cache,reconnect,defer_permissions,negative_vncache cd ~/remote; ls
If all goes well this should simply complete, substituting your username and server hostname in above. I recommend having SSH public key authentication turned on, else you’ll have to enter a password every time you’d like to mount this volume.
You’ll be able to browse the directory in Finder just like a normal directory, however it appears as a volume within a directory, and Finder masks the file name. No worries though, it’ll still work for applications that reference the path.
- Make it happen every time your login – Finally we can use a login hook to make this happen every time. Toss the mount command in a shell script:
#!/bin/bash sshfs andrew@someserver.com:/home/andrew/ ~/remote -oauto_cache,reconnect,defer_permissions,negative_vncache
Chmod the file 777 and run the following command to add the script to your login hook:
sudo defaults write com.apple.loginwindow LoginHook /path/to/script
Now every time you login, as long as you’re connected to the internet, you’ll have access to your files!