# ansible and ansible-playbook with ssh config not working...

**URL:** <https://forum.ansible.com/t/ansible-and-ansible-playbook-with-ssh-config-not-working/12459>\
**Category:** Ansible Project\
**Created:** [March 6, 2013, 3:23am UTC](https://forum.ansible.com/t/ansible-and-ansible-playbook-with-ssh-config-not-working/12459 "2013-03-06T03:23:23Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Curtis](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@Curtis](https://forum.ansible.com/u/Curtis)\
**Post date:** [March 6, 2013, 3:23am UTC](https://forum.ansible.com/t/ansible-and-ansible-playbook-with-ssh-config-not-working/12459/1 "2013-03-06T03:23:23Z")

</div>

Hi,

I would think this would just work? Usually I think wrong, so I guess I’m really wondering what I’ve got wrong here. 🙂

“virt-v2v” is the name of a host that is setup in .ssh/config…

# ansible -c ssh -u root -m ping virt-v2v

virt-v2v | success \>\> {  
“changed”: false,  
“ping”: “pong”  
}

# ansible-playbook -c ssh -u root veewee.yml

PLAY [veewee] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [virt-v2v] =\> failed to transfer file to /setup:

Permission denied (publickey,gssapi-keyex,gssapi-with-mic).  
Connection closed

TASK: [ensure correct packages are installed] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
FATAL: no hosts matched or all hosts have already failed – aborting

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
virt-v2v : ok=0 changed=0 unreachable=1 failed=0

# cat ansible\_hosts

[veewee]  
virt-v2v

---

<div class="post-metadata">

**Author:** ![Lorin\_Hochstein1](https://avatars.discourse-cdn.com/v4/letter/l/ce73a5/32.png) [@Lorin\_Hochstein1](https://forum.ansible.com/u/Lorin_Hochstein1)\
**Post date:** [March 6, 2013, 3:25am UTC](https://forum.ansible.com/t/ansible-and-ansible-playbook-with-ssh-config-not-working/12459/2 "2013-03-06T03:25:25Z")

</div>

Curtis:

Can you show the contents of your veewee.yml?

Take care,  
Lorin

---

<div class="post-metadata">

**Author:** ![Curtis](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@Curtis](https://forum.ansible.com/u/Curtis)\
**Post date:** [March 6, 2013, 3:29am UTC](https://forum.ansible.com/t/ansible-and-ansible-playbook-with-ssh-config-not-working/12459/3 "2013-03-06T03:29:56Z")

</div>

Oh, shoot, looking at that I've set the user to something other than root  
which is the user I need in this case.

# head veewee.yml

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [March 6, 2013, 4:25am UTC](https://forum.ansible.com/t/ansible-and-ansible-playbook-with-ssh-config-not-working/12459/4 "2013-03-06T04:25:58Z")

</div>

Ansible always specifies the user to ssh, so it will not pick it up  
from .ssh/config

---

<div class="post-metadata">

**Author:** ![Curtis](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@Curtis](https://forum.ansible.com/u/Curtis)\
**Post date:** [March 6, 2013, 5:20am UTC](https://forum.ansible.com/t/ansible-and-ansible-playbook-with-ssh-config-not-working/12459/5 "2013-03-06T05:20:39Z")

</div>

> Ansible always specifies the user to ssh, so it will not pick it up  
> from .ssh/config

Is that something that was decided ansible would not do? I think it would  
be pretty helpful to heavy ssh users, especially those who have servers  
that they access through a gateway ssh server. I suppose I should search  
the mailing list... 🙂

Thanks,  
Curtis.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [March 6, 2013, 4:42pm UTC](https://forum.ansible.com/t/ansible-and-ansible-playbook-with-ssh-config-not-working/12459/6 "2013-03-06T16:42:30Z")

</div>

> Is that something that was decided ansible would not do? I think it would be  
> pretty helpful to heavy ssh users, especially those who have servers that  
> they access through a gateway ssh server. I suppose I should search the  
> mailing list... 🙂

Basically Ansible is a systems management tool, not a user login tool.

In a given playbook, you may wish to log in from \*multiple\* different  
user accounts to the same box.

By ansible declaratively specifying the user, that makes this  
possible, and also makes it very clear  
from a self contained playbook what user is being used for the login,  
so it's repeatable -- the parameters  
are no longer needing the playbook \*AND\* the ssh config file, and  
users don't have to worry about the SSH  
config file unless they need, for example, jump hosts.

---

<div class="post-metadata">

**Author:** ![Curtis](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@Curtis](https://forum.ansible.com/u/Curtis)\
**Post date:** [March 6, 2013, 4:49pm UTC](https://forum.ansible.com/t/ansible-and-ansible-playbook-with-ssh-config-not-working/12459/7 "2013-03-06T16:49:20Z")

</div>

> \>  
> \> Is that something that was decided ansible would not do? I think it  
> would be  
> \> pretty helpful to heavy ssh users, especially those who have servers that  
> \> they access through a gateway ssh server. I suppose I should search the  
> \> mailing list... 🙂  
> \>
> 
> Basically Ansible is a systems management tool, not a user login tool.

> In a given playbook, you may wish to log in from \*multiple\* different  
> user accounts to the same box.
> 
> By ansible declaratively specifying the user, that makes this  
> possible, and also makes it very clear  
> from a self contained playbook what user is being used for the login,  
> so it's repeatable -- the parameters  
> are no longer needing the playbook \*AND\* the ssh config file, and  
> users don't have to worry about the SSH  
> config file unless they need, for example, jump hosts.

What would be wrong with honouring the .ssh/config if there is no user in  
the playbook or on the command line?

Thanks,  
Curtis.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [March 6, 2013, 5:09pm UTC](https://forum.ansible.com/t/ansible-and-ansible-playbook-with-ssh-config-not-working/12459/8 "2013-03-06T17:09:10Z")

</div>

Technically nothing, but it would need to work for /both/ SSHd and  
paramiko and only set things if no "-u" was specified either, and only  
if the user /was/ specified in the config, and not rely on a config  
being set.

In the case where there is no user specified, it uses the current user  
account or what is fed to "-u".

(Again, in our eyes, SSH is just the transport layer)

---

<div class="post-metadata">

**Author:** ![Curtis](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@Curtis](https://forum.ansible.com/u/Curtis)\
**Post date:** [March 6, 2013, 5:25pm UTC](https://forum.ansible.com/t/ansible-and-ansible-playbook-with-ssh-config-not-working/12459/9 "2013-03-06T17:25:07Z")

</div>

> Technically nothing, but it would need to work for /both/ SSHd and  
> paramiko and only set things if no "-u" was specified either, and only  
> if the user /was/ specified in the config, and not rely on a config  
> being set.
> 
> In the case where there is no user specified, it uses the current user  
> account or what is fed to "-u".
> 
> (Again, in our eyes, SSH is just the transport layer)

I definitely understand what you are saying in terms of ssh being the  
transport layer only.

That said, as a simple ansible user who has a lot of servers and  
environments to work with, some behind ssh jump hosts, thus massive use of  
.ssh/config, I find this to be a real big pain point. But that's just me. 🙂

Thanks,  
Curtis.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [March 6, 2013, 5:26pm UTC](https://forum.ansible.com/t/ansible-and-ansible-playbook-with-ssh-config-not-working/12459/10 "2013-03-06T17:26:37Z")

</div>

I have it on my list to look into this and avoid pass -u $user to ssh  
if it matches current user.  
Should not be to hard and it would enable .ssh/config

---

<div class="post-metadata">

**Author:** ![Seth\_Vidal](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@Seth\_Vidal](https://forum.ansible.com/u/Seth_Vidal)\
**Post date:** [March 6, 2013, 5:30pm UTC](https://forum.ansible.com/t/ansible-and-ansible-playbook-with-ssh-config-not-working/12459/11 "2013-03-06T17:30:45Z")

</div>

I'm confused here. You're having issues when you run with -c ssh using  
your .ssh/config ?

or is this only when using paramiko?

-sv

---

<div class="post-metadata">

**Author:** ![Zenobius\_Jiricek](https://avatars.discourse-cdn.com/v4/letter/z/c77e96/32.png) [@Zenobius\_Jiricek](https://forum.ansible.com/u/Zenobius_Jiricek)\
**Post date:** [August 15, 2013, 4:55am UTC](https://forum.ansible.com/t/ansible-and-ansible-playbook-with-ssh-config-not-working/12459/12 "2013-08-15T04:55:01Z")

</div>

Same here, it also makes using git hard when the git server requires access through a non standard ssh port and private key.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 15, 2013, 12:36pm UTC](https://forum.ansible.com/t/ansible-and-ansible-playbook-with-ssh-config-not-working/12459/13 "2013-08-15T12:36:22Z")

</div>

Please look up how GIT\_SSH works and so on.

This is basically just a function of git and not ansible.

You may wish to checkout your repositories over https:// to make things much easier for you, or deploy using packages, tarballs, or another mechanism if you wish to simplify the SSH checkout.
