How do I SSH into an EC2 instance from AWS gitlab-runner?

HOW TO -️ October 18, 2021

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, 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?


Hi @bynary ! Did you use private IP to connect to your EC2 instance ? I'm using the public IP. Is the private IP what is used for the security group communication across the VPC?