How do I SSH into an EC2 instance from AWS gitlab-runner? I have setup my own gitlab-runner on AWS following GitLab's walkthrough (Autoscaling GitLab Runner on AWS EC2).
One step in my deployment is to SSH into another EC2 instance. The SSH connection fails every time (see below for the one exception).
I have added an Inbound rule to my security group for the EC2 instance that allows SSH connections from the security group for both the gitlab-runner manager and the gitlab-runner machines. Still SSH connections are refused. Allowing SSH traffic from 0.0.0.0/0, however, causes the SSH connection from the gitlab-runner to the EC2 instance to succeed.
Why doesn't allowing my gitlab-runner security group in the inbound rules work, and how do I fix this so that I don't have to open my EC2 instance to the world to get SSH access from gitlab-runner?
When you use public IP the traffic exits your VPC and comes back in, at which point it is no longer identified as coming from that security group.
So you can adjust your ssh connection and use private IP