So, there I was looking for a way to directly access files on the development server with Komodo. Easy you say? Not if you need to use sftp/scp and public-key access. Turns out to be either really hard or just plain impossible. After a bit of kvetching to some online friends I was pointed to this article in the Komodo support forums. While I couldn’t get it to work in Komodo anyway, one of the comments did point me to a what promised to be a better solution anyway: mounting the remote filesystem as a volume on my trusty Mac. Now I have access to the what I need not just in Komodo, but in all my apps.
The solution is to use MacFUSE and sshfs to mount the remote filesystems using ssh for security. I hadn’t heard of MacFUSE before and was a bit skeptical about whether or not this was really going to work but it did. So here are the steps I took to make it work with my servers that require public-key access. Of course it works with plain old password access to servers, too.
- Run ssh-agent. It is part of the OpenSSH package and should already be part of your OSX install on the Mac.
- Export the SSH_AUTH_SOCK and SSH_AGENT_PID values returned when you run ssh-agent. This sets some environmental variables that get used by ssh-add in the next step to associate public-keys with your account.
- Use ssh-add <path-to-your-key> on the command line to add the keys you need to access your servers. Again it is part of the OpenSSH package on your Mac.
- Download latest MacFUSE .dmg from http://code.google.com/p/macfuse/downloads/list. Your probably going to want the Leopard version which also works fine on Snow Leopard.
- Download and install the SSH File System for MacFUSE from http://code.google.com/p/macfuse/wiki/MACFUSE_FS_SSHFS. On that same page follow the command line instructions to create mount points and launch sshfs.
That’s it. If all went well you should now see volumes on your Mac that correspond to the remote filesystems you mounted. There are a couple of things to keep in mind though. First, make sure that the account you used to log in to the server has read and write permissions for the directories and files you are accessing. I know it sounds obvious, but I was accessing the files on a development web tree and didn’t have the permissions I needed to write files.
Second, I leave it to those more skilled than I to figure out how to make all of this survive sleep mode or a reboot. Putting your Mac to sleep drops the net connections and they will not come back on waking up the machine unless you take extra steps. I’m not sure what happens to environmental variables on reboot because I haven’t rebooted since I did this, but I’m sure they will disappear to. If someone takes a crack at scripting all of this to keep going through sleep and reboot, let me know in the comments below.