Skip to content

How to mount Amazon ec2 drive locally – fuse + sshfs?

I use Amazon’s EC2 Elastic Compute Cloud heavily for personal development projects as well as at work for Globalme. I have been using scp to transfer files but that can get painful if you need to transfer files often. Looking for an easier solution, I found fuse + sshfs which can make file transfers a blast!. Using sshfs, you can mount your EC2 drive locally which can be a great time saver. I am using Ubuntu locally but fuse, sshfs and other required packages are available for other common distros as well.

We start with by installing the required packages

sudo aptitude install build-essential libcurl4-openssl-dev libxml2-dev libfuse-dev comerr-dev libfuse2 libidn11-dev libkadm55 libkrb5-dev libldap2-dev libselinux1-dev libsepol1-dev pkg-config fuse-utils sshfs

Add yourself to the fuse user group otherwise you will get a “permission denied” error later down the road

sudo usermod -a -G fuse your_username

Create a folder on your machine to be used as the mount point for the Amazon EC2 drive

sudo mkdir /mnt/ec2

Make yourself owner of this folder

sudo chown your_username:fuse /mnt/ec2

And finally mount your EC2 drive to the location. We will use the Amazon identity file. If you run the command without “-o IdentityFile,” remote machine will return “Connection reset by peer”

sshfs -o IdentityFile=Your_Identity_File.pem  [email protected]_host_address:/host_location_to_mount /mnt/ec2

One important thing to note… At my initial attempts mount was working fine but I kept getting the error message “You do not have the permissions necessary to view the contents of “ec2mount” when I tried to browse the mount point. I was running the sshfs command with sudo which caused permission conflicts with the remote user account. Leaving the sudo out kept the fuse and remote permissions in peace and I was able to browse.

A similar approach can be used for mounting an Amazon S3 Simple Storage bucket. You can find the instructions for that at this blog post Installing FUSE + s3fs and sshfs on Ubuntu

Categories: Linux tips.

Tags: , ,

Comment Feed

2 Responses

  1. In my Fedora there is no group called fuse. I think it was removed since F9. So, I just ignored him and used my own user group .

  2. great man, thanks a lot, it works like a charm (ubuntu 12.04), just a note for dummies (like me): “host_location_to_mount” is to be replaced by the path on the remote machine you want to mount

Some HTML is OK

or, reply to this post via trackback.