Installing vsftpd on an Amazon EC2 Ubuntu instance
Just a quick tutorial on the basic steps to get ftp setup and running on an Amazon EC2 instance. I assume you have already launched an ubuntu instance and have configured it for shell access (ssh).
Server Setup
First things first, lets open some ports for FTP. You can do this one of two ways:
Assuming you have a valid environment set up you can use the following two lines on the command line:
ec2-authorize default -p 20-21 ec2-authorize default -p 50000-51000
This assume the default security group, if you have a different security group then replace ‘default’ with it’s name.
If you’re not comfortable with the command line you can do it from your AWS management console.
- Just log in, go to EC2 and click the Security Groups link.
- Then choose the default group and switch to the inbound tab (at the bottom of the page)
- Add the port ranges as above (20-21 and 50000-51000) and apply the rule changes
Next log in (ssh) to your instance and execute:
sudo apt-get install vsftpd
Once that’s installed you need to run:
sudo vim /etc/vsftpd/vsftpd.conf
Now you need to uncomment the following lines (a comment begins with a ‘#’):
write_enable=YESand add the following lines at the bottom:
pasv_max_port=51000 pasv_min_port=50000 port_enable=YES pasv_enable=YES
This allows us to use PASV mode in our FTP program.
Now you probably want to add an FTP user to log in with. Since the default Ubuntu instances on EC2 usually require you to log in with your Private Key you need to add a user with a password. Luckily this is easy to do:
sudo adduser YOUR_USER_NAMEThen just follow the instructions on screen – including adding a password.
All that’s left to do is restart the FTP server:
sudo service vsftpd restartFileZilla Setup
Assuming you were going to use FileZilla (as this is what I use – instructions should be reasonable similar for WinSCP or any other program) go to File->Site Manager-Add New Site.
Host: YOUR_EC2_PUBLIC_DNS Port: 21 Protocol: FTP Encryption: Use plain FTP Logon Type: Normal User: USERNAME_YOU_CHOSE_IN_ADDUSER Password: PASSWORD_YOU_CHOSE_IN_ADDUSER Transfer Settings Tab: Transfer Mode: Passive
Hopefully this should then log in!
Leave a Reply