aws-cloudformation-templates icon indicating copy to clipboard operation
aws-cloudformation-templates copied to clipboard

SSH to EC2 in private vpc?

Open haoyanglu opened this issue 1 year ago • 2 comments

I would love to ssh to EC2 but there is no luck.

I am using ECS templates (private-vpc.yml + public-service.yml), in which the EC2 instance is not assigned a public ip address. In private-vpc.yml, there is a parameter KeyName, which indicates the key to access ec2. This also indicates ssh is doable? My question is how? If not, might be just delete this?

I also tried to associate an elastic ip to EC2 instance but still no luck. Would love some advice. Thanks.

haoyanglu avatar Mar 29 '23 08:03 haoyanglu

Hello haoyanglu, You cannot ssh directly into a private instance from your local machine. You can however connect to a private instance through a public instance in a public subnet. (The private instance's security group should allow connections from the SG(security group) of the public instances). To do this, you first ssh into the public instance and then ssh from the public instance to the private instance. Local---->Public---->Private

belisky avatar Apr 03 '23 11:04 belisky

This isn't really the right forum for this, but for the record it can now be done using an EC2 Instance Connect endpoint.

Aneurin avatar Jul 08 '23 12:07 Aneurin

Due to inactivity this issue will be closed in 7 days

github-actions[bot] avatar Apr 22 '24 19:04 github-actions[bot]