How to connect SSH to private AWS EC2 via windows bastion host

283 views
Skip to first unread message

venkat G

unread,
Jan 20, 2021, 5:08:38 PM1/20/21
to Packer
I am using the AWS Code build for creating Golden-ami using packer. We have a Windows bastion host for connecting private Ec2 Linux instances in AWS VPC. So my packer needs to connect EC2 in the private subnet via windows bastion host. Bastion host is in public subnet. 

I am getting the below SSH timed out error when i am running the pipeline.

 "associate_public_ip_address": "true",
    "vpc_id": "*****",
    "subnet_id": "*****",
    "security_group_id": "sg-****",
    "ssh_interface": "private_ip",
    "communicator": "ssh",
    "ssh_bastion_username": "***",
    "ssh_bastion_password": "****",
    "ssh_bastion_host":"*************",
    "ssh_bastion_port":"3389",
    "ssh_bastion_agent_auth": "true"


2021/01/20 20:37:09 packer: 2021/01/20 20:37:09 [INFO] Not using winrm communicator, skipping get password...
2021/01/20 20:37:09 packer: 2021/01/20 20:37:09 [INFO] Waiting for SSH, up to timeout: 5m0s
==> AWS AMI Builder - CIS: Pausing after run of step 'StepRunSourceInstance'. Press enter to continue. ==> AWS AMI Builder - CIS: Pausing after run of step 'StepGetPassword'. Press enter to continue. ==> AWS AMI Builder - CIS: Using ssh communicator to connect: 10.112.14.196
2021/01/20 20:37:09 ui error: ==> AWS AMI Builder - CIS: Error waiting for SSH: Error configuring bastion: SSH_AUTH_SOCK is not set
==> AWS AMI Builder - CIS: Waiting for SSH to become available...
==> AWS AMI Builder - CIS: Error waiting for SSH: Error configuring bastion: SSH_AUTH_SOCK is not set
==> AWS AMI Builder - CIS: Pausing before cleanup of step 'StepGetPassword'. Press enter to continue. ==> AWS AMI Builder - CIS: Pausing before cleanup of step 'StepRunSourceInstance'. Press enter to continue. ==> AWS AMI Builder - CIS: Terminating the source AWS instance...

Gabo Kete

unread,
Jan 22, 2021, 3:15:30 AM1/22/21
to Packer
This error looks like in your bastion the ssh server didn't started 

the SSH_AUTH_SOCK environment variable is set to point to a unix-domain socket used for communicating with the agent, and the SSH_AGENT_PID environment variable is set to the process ID of the agent

echo $SSH_AGENT_SOCK

Reply all
Reply to author
Forward
0 new messages