Setting up FTP on Amazon Cloud Server
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Running FTP on an Amazon EC2 server is possible, but it requires careful networking and security configuration to avoid fragile or unsafe deployments. Many teams use SFTP instead, yet some integrations still require classic FTP or FTPS. This guide shows a practical EC2 setup with vsftpd, passive mode, TLS, and least-privilege network rules.
Start with the Right Protocol Choice
Before installing anything, decide what your client systems support.
- SFTP uses SSH on one port and is usually simpler to secure.
- FTP sends credentials in clear text unless TLS is enabled.
- FTPS is FTP with TLS and is the safest option when FTP compatibility is required.
If your integration partner supports SFTP, use it. If they only support FTP semantics, configure FTPS and restrict inbound access to known source IP ranges.
EC2 and Security Group Preparation
Create an EC2 instance with a fixed public endpoint, either an Elastic IP or a DNS record pointing to a stable address. Then configure a security group with tight inbound rules.
For explicit FTPS in passive mode, you typically need:
- TCP 21 for control channel.
- A small passive range, for example TCP 40000 through 40010.
- Source restricted to trusted IPs.
Avoid opening the passive range to the entire internet unless absolutely required.
Install and Configure vsftpd
The following commands target Amazon Linux 2023. For Ubuntu, replace package commands with apt equivalents.
Create a dedicated FTP user and directory layout:
Now configure vsftpd with local users, chroot, passive mode, and TLS.
Generate a certificate and restart the service:
For production, replace the self-signed certificate with one issued by your internal PKI or a trusted certificate authority.
Validate End-to-End Connectivity
Server startup alone is not enough. You need to verify login, data transfer, and passive channel behavior from an external client.
Using lftp from a trusted machine:
If listing works but upload fails, the issue is usually passive-port networking. Recheck both:
- Security group inbound rules for passive range.
- Network ACL rules if your subnet uses restrictive ACL settings.
Hardening for Real Deployments
A secure setup includes more than TLS.
- Restrict source IPs to known partner addresses.
- Disable shell login for FTP users.
- Keep each user in isolated directories.
- Rotate credentials on a schedule.
- Monitor logs and alert on repeated failed logins.
Example log inspection commands:
For high-compliance environments, consider AWS Transfer Family instead of self-managed vsftpd. It reduces operational burden for certificates, patching, and availability.
Common Pitfalls
- Opening only port 21 and forgetting passive ports. Fix by defining a narrow passive range and opening it in the security group.
- Using plain FTP without TLS. Fix by forcing encrypted login and data channels.
- Leaving broad source access. Fix by restricting inbound CIDR blocks to partner networks.
- Setting
pasv_addressincorrectly. Fix by using the actual public endpoint that clients resolve. - Running FTP user with shell access. Fix by assigning
nologinand limiting directory permissions.
Summary
- Use FTPS when FTP compatibility is required, and prefer SFTP when possible.
- Configure
vsftpdwith passive mode, chroot, and forced TLS. - Align server config, security group rules, and subnet ACLs for data channel traffic.
- Validate transfers from an external client, not only from the instance itself.
- Apply least privilege across users, network rules, and operational access.

