Saturday, June 21, 2014

Mount Amazon EC2 instances on OS X with SSHFS

This gem lets you manipulate files on your remote EC2 instance as if they were local.  Think of it like a mini Dropbox near instantaneously updating files between your MacBook and your Ubuntu instance at Amazon.

Step 1: Configure SSH

Copy your Amazon .pem file to ~/.ssh
Change permissions on the .pem file:

chmod 600 ~/.ssh/myfile.pem

Test the .pem file:

ssh -i ~/.ssh/myfile.pem ubuntu@aws_instance_name.com

Store the .pem file in ssh so you can enter a shorter ssh command in the future:

ssh-add -K ~/.ssh/myfile.pem

Now you can ssh to your Ubuntu instance more easily:

ssh ubuntu@aws_instance_name.com

Step 2: Install SSHFS

Download and install both packages from http://osxfuse.github.io

OSXFUSE
SSHFS

Step 3: Configure the mount point

mkdir ~/AmazonEC2

sshfs ubuntu@aws_instance_name.com:/home/ubuntu/rails_projects ~/AmazonEC2

Now your EC2 files located at /home/ubuntu/rails_projects will be "synced" with ~/AmazonEC2

I do not think they are actually syncing - based on response times, I think file manipulations are done directly to the remote host.

For fun, take a look at mounted file systems:

df