# Failed to connect to the host via ssh: Connection timed out during banner exchange

**URL:** <https://forum.ansible.com/t/failed-to-connect-to-the-host-via-ssh-connection-timed-out-during-banner-exchange/36078>\
**Category:** Ansible Project\
**Tags:** kubernetes\
**Created:** [December 7, 2021, 8:01pm UTC](https://forum.ansible.com/t/failed-to-connect-to-the-host-via-ssh-connection-timed-out-during-banner-exchange/36078 "2021-12-07T20:01:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Justin\_Seiser](https://avatars.discourse-cdn.com/v4/letter/j/3ab097/32.png) [@Justin\_Seiser](https://forum.ansible.com/u/Justin_Seiser)\
**Post date:** [December 7, 2021, 8:01pm UTC](https://forum.ansible.com/t/failed-to-connect-to-the-host-via-ssh-connection-timed-out-during-banner-exchange/36078/1 "2021-12-07T20:01:22Z")

</div>

We have 2 environments, both showing the same problem.

ENV 1. Jenkins worker is in a Docker Container, running on a linux server  
ENV 2. Jenkins worker is a K8s pod.

The `container` the work is being ran from is the same in each env. This is the same container I am using locally to test.

We have tons of jobs that all use this same `ssh through a bastion` setup, but for some reason, just this one is having problem, even though other jobs, targeting the same servers are working fine.

We generate a ssh.cfg, which specifies the bastion and its configurations. The exact commands below, run just fine on everyone laptops, fail in the Jenkins pipeline.

```auto

[defaults]
stdout_callback = debug
ansible_connection = ssh
ansible_port = 22
retry_files_enabled = False
callbacks_enabled = timer, profile_tasks
gathering = smart
timeout = 60
forks = 1
serial = 1
[ssh_connection]
ssh_args = '-F ./ssh.cfg -o ControlMaster=auto -o ControlPersist=30m -o StrictHostKeyChecking=no -o ForwardAgent=yes -o ServerAliveInterval=30 -o UserKnownHostsFile=/dev/null'
pipelining = True

```

no\_proxy=’_’ ANSIBLE\_CONFIG=ansible-private.cfg ansible -i inventory/private\_linux\_aws\_ec2.yaml ‘tag\_DeploymentID\_${DEPLOYMENT\_ID}:!tag\_Role\_SSH\_Bastion\_Host’ -m ping -e ‘ansible\_python\_interpreter=/usr/bin/python2’  
no\_proxy=’_’ ANSIBLE\_CONFIG=ansible-private.cfg ansible-playbook -i inventory/private\_linux\_aws\_ec2.yaml playbooks/single\_private\_linux.yml -e “deployment\_id=${DEPLOYMENT\_ID} env=${ENV}”  
no\_proxy=’_’ ANSIBLE\_CONFIG=ansible-private.cfg ansible -i inventory/private\_windows\_aws\_ec2.yaml ‘tag\_DeploymentID\_${DEPLOYMENT\_ID}:!tag\_Role\_RDP\_Bastion\_Host’ -m win\_ping  
no\_proxy=’_’ ANSIBLE\_CONFIG=ansible-private.cfg ansible-playbook -i inventory/private\_windows\_aws\_ec2.yaml playbooks/single\_windows.yml -e “deployment\_id=${DEPLOYMENT\_ID} env=${ENV}”

When running `-vvv` you can copy/paste the SSH command it connects just fine.

Errors look like this, someones its all servers, sometime a few.

TASK [Set Fact - Public key] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
Tuesday 07 December 2021 19:56:53 +0000 (0:00:00.018) 0:00:04.729 \*\*\*\*\*\*  
ok: [ip-172-16-0-10.us-gov-west-1.compute.internal]  
ok: [ip-172-16-1-5.us-gov-west-1.compute.internal]  
ok: [ip-172-16-1-10.us-gov-west-1.compute.internal]  
ok: [ip-172-16-0-5.us-gov-west-1.compute.internal]

TASK [Remove New Authorized Keys file if exists] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
Tuesday 07 December 2021 19:56:54 +0000 (0:00:00.054) 0:00:04.784 \*\*\*\*\*\*

changed: [ip-172-16-0-10.us-gov-west-1.compute.internal]

fatal: [ip-172-16-1-5.us-gov-west-1.compute.internal]: UNREACHABLE! =\> {  
“changed”: false,  
“unreachable”: true  
}

MSG:

Data could not be sent to remote host “172.16.1.5”. Make sure this host can be reached over ssh: Connection timed out during banner exchange

ok: [ip-172-16-1-10.us-gov-west-1.compute.internal]

fatal: [ip-172-16-0-5.us-gov-west-1.compute.internal]: UNREACHABLE! =\> {  
“changed”: false,  
“unreachable”: true  
}TASK [Set Fact - Public key] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
Tuesday 07 December 2021 19:56:53 +0000 (0:00:00.018) 0:00:04.729 \*\*\*\*\*\*  
ok: [ip-172-16-0-10.us-gov-west-1.compute.internal]  
ok: [ip-172-16-1-5.us-gov-west-1.compute.internal]  
ok: [ip-172-16-1-10.us-gov-west-1.compute.internal]  
ok: [ip-172-16-0-5.us-gov-west-1.compute.internal]

TASK [Remove New Authorized Keys file if exists] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
Tuesday 07 December 2021 19:56:54 +0000 (0:00:00.054) 0:00:04.784 \*\*\*\*\*\*

changed: [ip-172-16-0-10.us-gov-west-1.compute.internal]

fatal: [ip-172-16-1-5.us-gov-west-1.compute.internal]: UNREACHABLE! =\> {  
“changed”: false,  
“unreachable”: true  
}

MSG:

Data could not be sent to remote host “172.16.1.5”. Make sure this host can be reached over ssh: Connection timed out during banner exchange

ok: [ip-172-16-1-10.us-gov-west-1.compute.internal]

fatal: [ip-172-16-0-5.us-gov-west-1.compute.internal]: UNREACHABLE! =\> {  
“changed”: false,  
“unreachable”: true  
}
