{
  "id": 8735606,
  "title": "Stop Whitelisting Port 22: SSH into Private EC2 from GitHub Actions via AWS SSM 🔐",
  "url": "https://urgent.news/2026/09/20/stop-whitelisting-port-22-ssh-into-private-ec2-from-github-actions",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-20T17:24:14.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/ankurk91/stop-whitelisting-port-22-ssh-into-private-ec2-from-github-actions-via-aws-ssm-cj4"
  },
  "original_language": "en",
  "account": "GitHub Actions jobs often need to transfer build artifacts to EC2 instances for further processing. Traditionally, this involves generating an SSH key pair, storing the private key as a secret and the public key in the instance's authorized_keys file. This approach has several drawbacks: the key never rotates, anyone who can access the secret can access the production instance, and the port 22 must be opened to allow inbound connections.\n\nA more secure solution is provided by AWS Systems Manager Session Manager (SSM). Session Manager allows SSH into EC2 instances without the need to open port 22 or manage keys. The SSM Agent running on the instance establishes an outbound HTTPS connection to AWS, creating a secure session that can be used to open a direct, encrypted tunnel for SSH. This approach eliminates the need for inbound security group rules, public IPs, bastion hosts, and key rotation.\n\nThe provided GitHub Action, ankurk91/setup-ssh-over-ssm-action, simplifies the process of setting up SSH via SSM. It automatically generates a short-lived SSH key, pushes it to the instance using EC2 Instance Connect, configures SSH to use SSM for the session, and cleans up after itself. All that's required is the instance ID, the user to log in as, and the AWS credentials with the necessary permissions. The action handles generating and managing the SSH key, so there's no need to maintain any secrets or keys in your workflow.",
  "summary": "😩 The part of CI/CD nobody enjoys You want a GitHub Actions job to rsync a build onto an EC2 box and restart a service. Simple, right? Then reality shows up: 🔑 The key. You generate an SSH key pair, paste the private half into secrets.SSH_PRIVATE_KEY , and append the public half to ~/.ssh/authorized_keys on the instance. That key now lives forever. It never rotates. Anyone who can read repo…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}