# SSH Config file not picked up during playbook execution.

**URL:** <https://forum.ansible.com/t/ssh-config-file-not-picked-up-during-playbook-execution/19677>\
**Category:** Ansible Project\
**Created:** [November 3, 2015, 1:18am UTC](https://forum.ansible.com/t/ssh-config-file-not-picked-up-during-playbook-execution/19677 "2015-11-03T01:18:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ayekaymail](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@ayekaymail](https://forum.ansible.com/u/ayekaymail)\
**Post date:** [November 3, 2015, 1:18am UTC](https://forum.ansible.com/t/ssh-config-file-not-picked-up-during-playbook-execution/19677/1 "2015-11-03T01:18:10Z")

</div>

Hello Folks,

I am trying to execute a playbook from the control machine in the internal network to a VM located in the DMZ as shown in the diagram below

[![](https://lh3.googleusercontent.com/-cLFiXDZUxPA/VjgEzhdtK_I/AAAAAAAAACY/fYFpZ0-6bgw/s1600/ansible-dmz.jpg)](https://lh3.googleusercontent.com/-cLFiXDZUxPA/VjgEzhdtK_I/AAAAAAAAACY/fYFpZ0-6bgw/s1600/ansible-dmz.jpg)

Access to the DMZ server is typically via a http proxy. I setup corkscrew to tunnel ssh over http and setup the configuration file as

~/.ssh/config

`  
Host Target.Server.VM.IP  
ProxyCommand /usr/local/bin/corkscrew HTTP.Proxy.Server.IP 80 %h %p

`

using this setting, I am manually able to ssh from the Control Machine to the Target VM directly.

However when the playbook executes it does not seem to read this config file and attempts a direct connection from the control server machine to the target VM in the DMZ. Both the playbook execution and the manual ssh connection are being executed under the same linux OS user

Can you please let me know if I am missing something at my end.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [November 3, 2015, 2:28am UTC](https://forum.ansible.com/t/ssh-config-file-not-picked-up-during-playbook-execution/19677/2 "2015-11-03T02:28:19Z")

</div>

As long as you don’t set the remote user (ssh limitation), the ssh config should be picked up automatically (just tested and works).

---

<div class="post-metadata">

**Author:** ![ayekaymail](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@ayekaymail](https://forum.ansible.com/u/ayekaymail)\
**Post date:** [November 3, 2015, 2:49am UTC](https://forum.ansible.com/t/ssh-config-file-not-picked-up-during-playbook-execution/19677/3 "2015-11-03T02:49:40Z")

</div>

Thanks Brian

Unfortunately, its not working for me. It still tries to make a direct connection

`  
-bash-4.1$ export ANSIBLE\_SSH\_ARGS=“-F /var/lib/awx/.ssh/config” ; ansible-playbook -i /opt/ansiblework/inventory/dmzhosts helloworld.yml -u webuser --ask-pass -vvvv  
SSH password:

PLAY [Hello World!] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
\<Target.Server.VM.IP\> ESTABLISH CONNECTION FOR USER: webuser on PORT 22 TO Target.Server.VM.IP  
fatal: [Target.Server.VM.IP] =\> {‘msg’: ‘FAILED: [Errno 111] Connection refused’, ‘failed’: True}

TASK: [Hello World!] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
FATAL: no hosts matched or all hosts have already failed – aborting

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
to retry, use: --limit @/var/lib/awx/helloworld.retry

Target.Server.VM.IP : ok=0 changed=0 unreachable=1 failed=0

`

Not sure what I am missing here

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [November 3, 2015, 2:52am UTC](https://forum.ansible.com/t/ssh-config-file-not-picked-up-during-playbook-execution/19677/4 "2015-11-03T02:52:41Z")

</div>

As I mentioned, if you set the remote user, it will ignore the .ssh  
config and you have `-u webuser`

---

<div class="post-metadata">

**Author:** ![ayekaymail](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@ayekaymail](https://forum.ansible.com/u/ayekaymail)\
**Post date:** [November 3, 2015, 2:56am UTC](https://forum.ansible.com/t/ssh-config-file-not-picked-up-during-playbook-execution/19677/5 "2015-11-03T02:56:38Z")

</div>

tried removing the -u webuser. still the same issue

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [November 3, 2015, 3:18am UTC](https://forum.ansible.com/t/ssh-config-file-not-picked-up-during-playbook-execution/19677/6 "2015-11-03T03:18:08Z")

</div>

weird, w/o the user it picks up my ssh config, including jumphost line  
w/o any issues. In any case you can also pass that info in the  
ansible\_ssh\_args per host/group
