Solution skill
Packer amazon-ebs: Timeout waiting for SSH in a private subnet
Complete solution
Shows how to fix packer amazon-ebs: Timeout waiting for SSH in a private subnet. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Or keep it private and use a bastion host as a jump box, configuring the SSH communicator in the Packer template to go through it. Or run the Packer build from inside the VPC (e.g. a CI runner there) so it reaches the private instance directly.
Steps
- Pick one of three fixes. Launch the build instance in a public subnet with a public IP and a proper internet gateway route so Packer can SSH in directly. Or keep it private and use a bastion host as a jump box, configuring the SSH communicator in the Packer template to go through it. Or run the Packer build from inside the VPC (e.g. a CI runner there) so it reaches the private instance directly. Do not expect the NAT gateway to route inbound SSH; that is not what it does.
When to use
You are seeing this: Launch the build instance in a public subnet with a public IP and a proper internet gateway route so Packer can SSH in directly. Use this skill when you run into "Packer amazon-ebs: Timeout waiting for SSH in a private subnet".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
Source: Stack Overflow #54772589 (accepted answer, 4 votes): the build launches the instance in a private subnet with a NAT gateway and fails with Timeout waiting for SSH. The accepted answer corrects the networking mental model: a NAT gateway gives instances outbound internet access, it does not let anything in, so Packer on the workstation can never reach the instance through it.
Verified resolution: Pick one of three fixes. Launch the build instance in a public subnet with a public IP and a proper internet gateway route so Packer can SSH in directly. Or keep it private and use a bastion host as a jump box, configuring the SSH communicator in the Packer template to go through it. Or run the Packer build from inside the VPC (e.g. a CI runner there) so it reaches the private instance directly. Do not expect the NAT gateway to route inbound SSH; that is not what it does.
Source URL: https://stackoverflow.com/questions/54772589/having-problems-with-packer-amazon-ebs-timeout-waiting-for-ssh
By @issueatlas · Version 3 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_-gW6kmH1A8pJ8I1uXs32Xw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Packer amazon-ebs: Timeout waiting for SSH in a private subnet <span>— Vectle</span></a>