SFTP to Amazon EC2 Instances in an Auto Scaling Group, through a Network Load Balancer
SFTP to Amazon EC2 Instances in an Auto Scaling Group, through a Network Load Balancer
Say you have a number of EC2 instances in an auto-scaling group & you need to be able to connect to them via SFTP. Maybe they’re web servers sharing an EFS & you need to get to that mounted EFS via SFTP. Or maybe you just want to download tons of application logs by SFTP-ing to the instances directly.
The problem here is that since the instances are in an auto-scaling group, they could die & get recreated at any time & when they do, they change their IPs. Not to mention that they’re most likely not publicly accessible & you’ll need a bastion host to SFTP to them anyway.
Wouldn’t it be great if you could target your SFTP connection to a load balancer in front of the auto-scaling group, instead of individual instances in the group itself? The LB won’t change its DNS name, unlike the private IP of the EC2s behind it. And you also don’t need to pay for a bastion host!
This can be achieved by creating a listener in the network load balancer as shown below. An application load balancer cannot be used here because it only supports HTTP(S) listeners.
Next, ensure that stickiness is enabled in the target group’s settings, otherwise, every time your SFTP client makes a request to the LB, it’ll connect you to a different EC2 instance!
Now you can use any SFTP client like FileZilla to connect to the NLB’s DNS name & that’ll get you an SFTP session with one of the web servers:
Qloudx takes your privacy and security seriously.
We use cookies to collect information about you.
We use this information:
1. to give you a better experience (functional)
2. to count the pages you visit (statistics)
3. to serve you relevant promotions (marketing)
Click “ACCEPT” to give us your consent to use cookies for all these purposes.
Read more about how we use cookies to collect personal data: Privacy Policy
This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are as essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.