# Point Ansible at alternate ssh config file

**URL:** <https://forum.ansible.com/t/point-ansible-at-alternate-ssh-config-file/23741>\
**Category:** Ansible Project\
**Created:** [February 15, 2017, 6:50pm UTC](https://forum.ansible.com/t/point-ansible-at-alternate-ssh-config-file/23741 "2017-02-15T18:50:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff\_Richards](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@Jeff\_Richards](https://forum.ansible.com/u/Jeff_Richards)\
**Post date:** [February 15, 2017, 6:50pm UTC](https://forum.ansible.com/t/point-ansible-at-alternate-ssh-config-file/23741/1 "2017-02-15T18:50:39Z")

</div>

I’m trying to have Ansible use an alternate ssh config file (i.e. not ~/.ssh/config).

My understanding was that you achieve this via adding a -F option in ssh\_args in /etc/ansible/ansible.cfg. So my ssh\_args now looks like this:

[ssh\_connection]  
ssh\_args = -C -F ~/.ssh/collated-configs -o ControlMaster=auto -o ControlPersist=30m -o ControlPath=/tmp/ansible-ssh-%h-%p-%r

but collated-configs never gets referenced.

Any thoughts appreciated.

Jeff

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [February 15, 2017, 8:36pm UTC](https://forum.ansible.com/t/point-ansible-at-alternate-ssh-config-file/23741/2 "2017-02-15T20:36:26Z")

</div>

Jeff,

If memory serves me correctly, you have to use a full path to the config, and cannot use ~

This is due to the ssh command not being executed via a shell, so shell expansions do not happen.

I have a similar configuration in my ansible.cfg and it works without issue.

---

<div class="post-metadata">

**Author:** ![Jeff\_Richards](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@Jeff\_Richards](https://forum.ansible.com/u/Jeff_Richards)\
**Post date:** [February 15, 2017, 9:23pm UTC](https://forum.ansible.com/t/point-ansible-at-alternate-ssh-config-file/23741/3 "2017-02-15T21:23:18Z")

</div>

Hey Matt,

Tried it both ways, makes no difference.

With verbosity cranked up, I can see that it’s reading the default .ssh/config file.

But interestingly, although the debug does show:  
“Using /etc/ansible/ansible.cfg as config file”

and that contains:

ssh\_args = -C -F /home/user01/.ssh/collated-configs -o ControlMaster=auto -o Co  
st=30m -o ControlPath=/tmp/ansible-ssh-%h-%p-%r

the SSH: debug does not reflect any of those ssh\_args.

So if we’re not reading /etc/ansible/ansible.cfg at all, that would explain this behavior. But what would cause that to silently fail?

Jeff
