Due to the constantly-changing ocean of active cloud instances on the AWS network it assigns public and private IPs dynamically. This means that FTP has to be configured for passive mode (requiring the public IP) when an instance is created (eg in an auto scaling cluster) you’d have to log in and manually fix the configs. Growing tired of this very quickly, I whipped up a quick solution where the instance would fix itself.
The solution is simple: every time the instance reboots or is spun up for the first time it runs a script that queries the EC2 metadata and updates the FTP config with the current public IP.
The script can be found here. You’ll need to update the sed line if you don’t use vsftpd.
All you need to do is make the script executable and add it to /etc/rc.local. Obviously, the script user will need sufficient permissions to alter the config file and restart the daemon.
And that’s pretty much it. A simple solution to a rather specific problem but it keeps the devs happy and the support requests down :)
Delete Queues In RabbitMQ
Allow IPs to Bypass Apache Authentication