EC2 ssh sftp fuse on OSX made easy 2
I’m deploying a cluster of servers on Amazon EC2 in my job, It’s a really cool technology. I’m setting up the servers to use puppet as an administration tool, but haven’t gotten very far in that yet. I am still at the configure the image stage.
One thing that really bugged me is this. I manage the AMI instance and the EBS volumes using the Elastifox plugin for firefox. There are command line tools too, but a gui is way easier here. One of the cool features in the gui is when you right click on an AMI instance and hit “Connect to Public DNS Name”, elasticfox will open a terminal and ssh to that server automaticly.
I then would copy the new for-this-session-only AMI dns name, Open my SFTP client and paste it in, set up the public key and connect. This last step sucks, It takes 30 seconds minimum every time, 10-20 times a day. I modified the script provided with elastifox, to work with the great google project MacFUSE which mounts SFTP Volumes just like drives in OSX finder. Now I right click on an instance, it opens SSH and mounts the drive for drag and drop ease.
Here’s what I did.
This site provided alot of help for me
Install the Elasticfox Firefox plugin. Read the Documentation
Click the Tools button in Elasticfox.
Enter your data in the blue highlighted area.

#add this code
-e 'on run argv' -e 'tell app "System Events" to set termOn to (exists process "Terminal")' -e 'set cmd to "mkdir /Volumes/" & item 3 of argv & ";sshfs -C -o idmap=user -o uid=502 -o gid=20 -o allow_other " & item 2 of argv & "@" & item 3 of argv & ":/ /Volumes/" & item 3 of argv & " -oIdentityFile=" & item 1 of argv & ",reconnect,noappledouble,ping_diskarb,follow_symlinks,noreadahead,volname=" & item 1 of argv & ";ssh -L10000:localhost:10000 -L3307:localhost:3306 -L8081:localhost:8080 -L3080:www2.flyspy.com:80 -L4849:localhost:4848 -i " & item 1 of argv & " " & item 2 of argv & "@" & item 3 of argv & ";"' -e 'if (termOn) then' -e 'tell app "Terminal" to do script cmd' -e 'else' -e 'tell app "Terminal" to do script cmd in front window' -e 'end if' -e 'tell app "Terminal" to activate' -e 'end run' ${key} ${user} ${host}
#NOTE you have to replace the uid and gid number with YOUR OSX uid and gid.
To find these open up a terminal and type "id" (no quotes)
Install MacFuse
Once MacFuse is installed make a symbolic link in the terminal, the following code may not be pointed at the correct file, so double check it.
sudo ln /Applications/sshfs.app/Contents/Resources/sshfs-static-10.5 /usr/local/bin/sshfs
sudo ln /Applications/sshfs.app/Contents/Resources/sshnodelay.so /usr/local/lib/
Thats it! Right click on an ami, and ssh will open and Finder will mount the instance, via ssh.
If you need to set up tunnels ( for mysql admin and such ) modify the command and add the ssh tunnel “-L3307:127.0.0.1:3306” between “ssh -i”. Then use your admin tool and connect up to localhost:3307
If Volumes dont show up, on desktop: check show connected servers on desktop in the Finder Preferences.

Hi Joel,
You could also consider something like ddclient (with DynDNS) to give your instances names when you start up. I now fireup new instances and immediately access them by name like myserver1.gotdns.com, myserver2.gotdns.com, etc. I use the same key per image type. I never have to concern myself with the public amazon-assigned name.
Thanks for the script for elasticfox, I will give it a go on my MBP!
Hi Joel,
great that you could use my research on that MacFUSE+sshfs topic.
Helmut