Packer "Timeout waiting for SSH" in CI
Packer builds by connecting over SSH to run provisioners. If the security group blocks port 22, the key does not match, or the ssh_username is wrong, Packer waits and then times out.
What this error means
packer build prints "Waiting for SSH to become available..." repeatedly, then fails with "Timeout waiting for SSH" and tears down the instance.
==> amazon-ebs.ubuntu: Waiting for SSH to become available...
==> amazon-ebs.ubuntu: Timeout waiting for SSH.
Build 'amazon-ebs.ubuntu' errored after 5 minutes: Timeout waiting for SSH.Common causes
A security group that blocks inbound SSH
Port 22 is not open from the runner (or Packer temporary security group is not created), so the connection never establishes.
A wrong ssh_username for the AMI
Using root on Ubuntu (which needs ubuntu) or the wrong user for the image makes every SSH attempt fail.
How to fix it
Set the correct ssh_username and open SSH
- Set
ssh_usernameto the AMI default (ubuntu,ec2-user,admin). - Ensure a security group allows inbound TCP 22 from where Packer connects.
- Re-run the build and watch for a successful SSH connection.
source "amazon-ebs" "ubuntu" {
ssh_username = "ubuntu"
temporary_security_group_source_cidrs = ["0.0.0.0/0"]
}Route to a private instance
If the instance has no public IP, connect over a bastion or set ssh_interface = "session_manager" so Packer can reach it.
ssh_interface = "session_manager"How to prevent it
- Use the correct
ssh_usernamefor each source AMI. - Allow inbound SSH from the build network or use Session Manager.
- Give private-subnet builds a bastion or SSM path.