What I found, however was a configuration nightmare. OK, truly, it wasn't that bad, but my inexperience with setting up FTP servers really became a bottleneck. So for future reference, and for anyone attempting the same, here is the script I came up with, after much trial and error.
- Create your ec2 instance:
- In my case, I used "CentOS 7 (x86_64) - with Updates HVM" from the marketplace as it is my goto AMI.
- I selected a t2.nano, as I know the traffic to this server will be minimal.
- I chose the correct VPC and Subnet to ensure public accessability.
- I then chose a moderately sized magnetic volume as I know that the load will be minimal.
- For security groups, I have configured a security group for each use case. This allows me to easily add and remove security groups to each server as needed. Simply looking at the list of groups shows me what permissions have been added. I added my internal group, FTP for port 21 & 22, and FTP - passv for the port range that I selected in pasv mode (see step x below). Depending on your setup, you may also want to add port 22 to allow ssh access. That is built into my internal group.
- Next I added the appropriate keys and launched my server.
- Then, I added an elastic IP address so that I can easily swap instances if needed.
- Finally, I added a dns record pointing to the elastic ip.
- Configure your instance:
- SSH into your instance and give yourself root access: sudo su
- Update the server: yum -y update
- Install vsfptd: yum -y install vsftpd
- Configure vsftpd by editing vsftpd.conf, adding the following to the bottom of the config file, replacing the min/max ports with whatever range you would like, and the pasv_address to the elastic ip you assigned above:
- Add an FTP user: useradd -d /home/ftpuser -s /sbin/nologin ftpuser
- Set the Password: passwd ftpuser.
- You could stop there, but you might get an error like this: "500 OOPS: vsftpd: refusing to run with writable root inside chroot ()"
- To fix that, adjust the permissions of the directory: chmod a-w /home/ftpuser
- Then run: setsebool -P allow_ftpd_full_access 1
That should be it! In my case I also setup an rsync script in my production server's crontab to populate the files onto the ftp server.