password - setup ftp on amazon ec2 ubuntu




Uploading to EC2 problems. How do you do FTP? (3)

Adding the key to www is a recipe for disaster! Any minor issue with your app will become a security nightmare.

As an alternative to ftp, consider using rsync or a more "mature" deploy strategy based on capistrano for instance. There are plenty of tools for that around.

I have setup a new EC2 instance on AWS and I'm trying to get FTP working to upload my application. I have installed VSFTPD as standard, so I haven't changed anything in the config file (/etc/vsftpd/vsftpd.conf).

I have not set my port 21 in the security group, because I'm doing it through SSH. I log into my EC2 through termal like so

sudo ssh -L 21:localhost:21 -vi my-key-pair [email protected]

I open up filezilla and log into local host. Everything goes fine until it comes to listing the directory structure. I can log in and right and everything seems fine as you can see below:

Status: Resolving address of localhost
Status: Connecting to [::1]:21...
Status: Connection established, waiting for welcome message...
Response: 220 Welcome to EC2 FTP service.
Command: USER anonymous
Response: 331 Please specify the password.
Command: PASS ******
Response: 230 Login successful.
Command: OPTS UTF8 ON
Response: 200 Always in UTF8 mode.
Status: Connected
Status: Retrieving directory listing...
Command: PWD
Response: 257 "/"
Command: TYPE I
Response: 200 Switching to Binary mode.
Command: EPSV
Response: 229 Entering Extended Passive Mode (|||37302|).
Command: LIST
Error: Connection timed out
Error: Failed to retrieve directory listing

Is there something which I'm missing in my config file. A setting which needs to be set or turned off. I thought it was great that it connected but when it timed out you could picture my face. It meant time to start trawling the net try and find the answer! Now with no luck.

I'm using the standard Amazon AMI 64 bit. I have a traditional lamp setup.

Can anyone steer me in the right direction? I have read a lot about getting this working but they are all incomplete, as if they got bored half way through typing up how to do it.

I would love to hear how you guys do it as well. If it makes life easier. How do you upload your apps to a EC2 instance? (Steps please - it saves a lot of time plus it is a great resource for others.)


Antti Haapala's tips are the only way to work around with EC2 SFTP. It works just fine! Just note that you need to create the /var/www/.ssh/ folder and copy the authorized_keys file there.

After that you'll need to change authorized_keys ownership to www-data so ssh connection can recognize it. Amazon should let people know that. I looked for this in there forums, FAQ, etc. No clue at all... Cheers once more to , the way to go haha!


I figured it out, after the direction help by Antti Haapala.

You don't even need VSFTP setup on the instance created. All you have to do is make sure the settings are right in FileZilla.

This is what I did (I'm on a mac so it should be similar on windows):

  1. Open up file zilla and go to preferences.
  2. Under preferences click sftp and add a new key. This is your key pair for your ec2 instance. You will have to convert it to the format FileZilla uses. It will give you a prompt for the conversion
  3. Click okay and go back to site manager
  4. In site manager enter in your EC2 public address, this can also be your elastic IP
  5. Make sure the protocol is set to SFTP
  6. Put in the user name of ec2-user
  7. Remove everything from the password field - make it blank
  8. All done! Now connect.

That's it you can now traverse your EC2 system. There is a catch. Because you are logged in as ec2-user and not root you will not be able to modify anything. To get around this, change the group ownership of the directory where your application will lie (/var/www/html) or what ever. I would change it so it is on a EBS volume. ;) Also make sure this group has read write and execute permissions. The group for the ec2-user is ec2-user. Leave everyone else as nothing. So the command you use while logged in via ssh

sudo chgrp ec2-user file/folder
sudo chmod 770 file/folder

Hope this helps someone.