Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ssh and sftp into an ec2 behind an elastic load balacer without elastic ip address

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?

like image 689
Rocky Avatar asked Feb 17 '15 05:02

Rocky


People also ask

How do I SSH into my EC2 instance without public IP?

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.

Can you SSH to your private machines that reside in a VPC from outside without elastic IP?

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.

Do I need an elastic IP for my EC2 instance?

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.


1 Answers

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

  1. TCP Port 2222(ELB) to 22 (Instance) enter image description here

  2. 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] enter image description here

  3. Get the Connection Established [the IP 14.0.1.87 is ELB's ID and not the public IP of my machine] enter image description here

like image 95
Naveen Vijay Avatar answered Sep 19 '22 17:09

Naveen Vijay