I have been trying to figure out a way to ssh into an ec2 instance behind an elastic load balancer without assigning the ec2 instance an Elastic IP
Usually I would assign an Elastic IP onto an ec2 instance and just SSH and SFTP through that way but is their another way ,I can ssh and sftp without assigning it an elastic ip through PuTTy?
If the instance does not have a public IP address, you can connect to the instance over a private network using an SSH client or the EC2 Instance Connect CLI. For example, you can connect from within the same VPC or through a VPN connection, transit gateway, or Amazon Direct Connect.
Your instance won't NEED an elastic IP. You'll get a public IP if you put the VM in your default VPC. But note that this IP might and will change if you reboot the instance. In short, no you won't need an elastic ip, but it's very handy.
The Elastic IP should be assigned to an instance, if it is not assigned you may incurr additional billing for idle time usage. So if you have any unassigned Elastic IP address, make sure to remove them. Once you create a new EC2 Instance your instance will get a new public IP address.
I tried this configuration - the ELB port to be 2222 and the Instance port to 22. It worked for me. For simplicity I used the same SG for both EC2 and ELB.
Similarly you can route the PORT 2220
to 20
, 2221
to 21
like this for SFTP
TCP Port 2222(ELB) to 22 (Instance)
Open Putty and enter the ELB DNS with Port 2222 [Be sure if the 2222 is opened to your exit IP of office / public IP via. the SG]
Get the Connection Established [the IP 14.0.1.87 is ELB's ID and not the public IP of my machine]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With