Right Outer Join

21 March 2012

FileZilla and EC2 using private keys

Filed under: Uncategorized — Tags: , , , , , — mdahlman @ 10:05

SSH and EC2 using private keys

I have used Amazon EC2 for a few years. We often use RightScale on top of EC2 to manage things. We always use private keys to login rather than passwords. I nearly always connect like this:

     ssh -i ~/my_private_key root@my_ec2_instance

SCP and EC2 using private keys

At first I didn’t have a simple way to upload files from my laptop to my EC2 instance. I would upload files via FTP from my machine to an FTP server somewhere. Then I would SSH to the EC2 instance. Then I would FTP the file down to that instance. It worked. But it’s a lot more painful than it ought to be. Eventually I learned the correct way to do it in one step:

     scp -i ~/my_private_key /Users/mdahlman/temp/messages.json root@my_ec2_instance:/tmp

FileZilla and EC2 using private keys

The above ‘scp’ example works well. It saves me all of the FTP shenanigans I was going through before. But sometimes a GUI is simpler to use. I use FileZilla for many similar tasks. But I could not get FileZilla to do an scp copy when the connection had to use a private key to connect. First, FileZilla completely rejected the idea of adding the ability to transfer files via SCP.

Please add Secure Copy Protocol (SCP) support – Ticket #4147 (closed Feature request: rejected)

So I gave up. Eventually I realized that this is not true. It would be nice if the FileZilla folks would update that rejected feature request to indicate that the feature was indeed added at a later time.

Later someone let me know that FileZilla can indeed use SCP despite the above issue. Woo hoo! I un-gave-up. It worked immediately for a server with a username and password. But I could not figure out how to use a private key. I googled, and I ranted. But I found nothing.

I re-gave-up. But then one day I randomly came across this post which links to this post. It describes how to use FileZilla to connect to EC2 using private keys. Hooray!

I re-un-gave-up. It worked! It’s written from a Window-centric standpoint. But it contains the key information. For the benefit of other Mac OS X users, here is the Mac-ified version of what to do.

FileZilla (on Mac OS X) and EC2 using private keys

Starting point: you already know how to connect to your EC2 server via SSH using your private key. If you don’t, then Google up some other article explaining what to do. If you do, then read on.

Open the SiteManager (File → Site Manager…). Create a new Site with the protocol SFTP and logon type Normal. I use the default port 22, so I didn’t bother entering it. Click OK to save it. (Don’t click Connect. It won’t work yet.)

FileZilla 3.5.3 Site Manager defining a connection to an Amazon EC2 server using a private key for authentication

Now the good part: define your private key!

FileZilla → Preferences…  In the section SFTP add a keyfile. In my case it had to convert the format of my keyfile. But it did this automatically, so I didn’t need to know any extra details. That’s it.

Then connect to the newly defined site. I can browse the files on my EC2 instances then upload and download to my heart’s content.

The Silver is the New Black Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 40 other followers