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.



  1. You are a legend for this, now I don’t have to rely on Cyberduck’s laggy GUI for this sort of thing.

    Would recommend this guide to anyone else in similar situations any day.

    Comment by Luke — 31 May 2012 @ 05:07

  2. It works just fine on windows too! Thanks for sharing.

    Comment by Mal — 18 September 2012 @ 13:33

  3. Finally! Thankyou thankyou thankyou! (Win 7)

    Final piece for me was using ec2-user, not root.

    Comment by Ed Leckert — 3 November 2012 @ 13:21

  4. […] going with the latter, I use FileZilla to transfer over any data I need to my Linux instance. See this post for getting it to work with your authentication […]

    Pingback by Lazy D3 on some astronomical data « Drunks&Lampposts — 3 January 2013 @ 13:38

  5. Outstanding! Exactly what I needed to know. Worked like a charm. Thanks for taking the time to share this.

    Comment by Fornzix — 6 February 2013 @ 20:17

  6. […] is really just my take on a beautiful existing post (I love “re-un-gave up”, which is a verb I never knew existed even though I experience […]

    Pingback by Amazon AWS – SFTP with Filezilla « Almost All Digital — 13 February 2013 @ 06:39

  7. Thanks. There were lots of articles about getting FileZilla to import the ssh key, or how to convert it to a usable type, but yours was the only one that described the important bit about setting logon type to ‘Normal’ to enable it.

    Comment by superkuh — 20 February 2013 @ 06:54

  8. Windows link is not working 😦 please share it.

    Comment by vani — 16 October 2013 @ 17:36

  9. Well done mate!

    Comment by mki — 31 December 2013 @ 05:54

  10. […] going with the latter, I use FileZilla to transfer over any data I need to my Linux instance. See this post for getting it to work with your authentication […]

    Pingback by coppelia | Lazy D3 on some astronomical data — 2 June 2014 @ 03:28

RSS feed for comments on this post. TrackBack URI

Go on... leave a reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: