# Manual git clone (locally) works, but same command using ansible (localhost) fails

**URL:** <https://forum.ansible.com/t/manual-git-clone-locally-works-but-same-command-using-ansible-localhost-fails/15593>\
**Category:** Ansible Project\
**Created:** [July 2, 2014, 5:00pm UTC](https://forum.ansible.com/t/manual-git-clone-locally-works-but-same-command-using-ansible-localhost-fails/15593 "2014-07-02T17:00:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ken\_Lemoine](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@Ken\_Lemoine](https://forum.ansible.com/u/Ken_Lemoine)\
**Post date:** [July 2, 2014, 5:00pm UTC](https://forum.ansible.com/t/manual-git-clone-locally-works-but-same-command-using-ansible-localhost-fails/15593/1 "2014-07-02T17:00:12Z")

</div>

Hello,

I can run this command successfully on my ansible server -

git clone [git@github.com](mailto:git@github.com):path/repo.git

However, this command fails (see verbose ssh output below). ‘local’ is a host inventory group consisting of ‘localhost’.

ansible local -a “git clone [git@github.com](mailto:git@github.com):patch/repo.git” -vvvv

This is a new ansible install on a new server, so I’m stumped. The same SSH keys and setup work on my older ansible server. Any assistn

Verbose output:

ESTABLISH CONNECTION FOR USER: klemoine  
 REMOTE\_MODULE command git clone [git@github.com](mailto:git@github.com):path/repo.git  
 EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/home/klemoine/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘StrictHostKeyChecking=no’, ‘-o’, ‘Port=22’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘ConnectTimeout=10’, ‘localhost’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1404319017.45-175813341407778 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1404319017.45-175813341407778 && echo $HOME/.ansible/tmp/ansible-tmp-1404319017.45-175813341407778’”]  
localhost | FAILED =\> SSH encountered an unknown error. The output was:  
OpenSSH\_5.9p1 Debian-5ubuntu1.4, OpenSSL 1.0.1 14 Mar 2012  
debug1: Reading configuration data /etc/ssh/ssh\_config  
debug1: /etc/ssh/ssh\_config line 19: Applying options for \*  
debug1: auto-mux: Trying existing master  
debug1: Control socket “/home/klemoine/.ansible/cp/ansible-ssh-localhost-22-klemoine” does not exist  
debug2: ssh\_connect: needpriv 0  
debug1: Connecting to localhost [127.0.0.1] port 22.  
debug2: fd 3 setting O\_NONBLOCK  
debug1: fd 3 clearing O\_NONBLOCK  
debug1: Connection established.  
debug3: timeout: 10000 ms remain after connect  
debug3: Incorrect RSA1 identifier  
debug3: Could not load “/home/klemoine/.ssh/id\_rsa” as a RSA1 public key  
debug1: identity file /home/klemoine/.ssh/id\_rsa type -1  
debug1: identity file /home/klemoine/.ssh/id\_rsa-cert type -1  
debug1: identity file /home/klemoine/.ssh/id\_dsa type -1  
debug1: identity file /home/klemoine/.ssh/id\_dsa-cert type -1  
debug1: identity file /home/klemoine/.ssh/id\_ecdsa type -1  
debug1: identity file /home/klemoine/.ssh/id\_ecdsa-cert type -1  
debug1: Remote protocol version 2.0, remote software version OpenSSH\_6.6  
debug1: match: OpenSSH\_6.6 pat OpenSSH\*  
debug1: Enabling compatibility mode for protocol 2.0  
debug1: Local version string SSH-2.0-OpenSSH\_5.9p1 Debian-5ubuntu1.4  
debug2: fd 3 setting O\_NONBLOCK  
debug3: load\_hostkeys: loading entries for host “localhost” from file “/home/klemoine/.ssh/known\_hosts”  
debug3: load\_hostkeys: found key type ECDSA in file /home/klemoine/.ssh/known\_hosts:60  
debug3: load\_hostkeys: loaded 1 keys  
debug3: order\_hostkeyalgs: prefer hostkeyalgs: [ecdsa-sha2-nistp256-cert-v01@openssh.com](mailto:ecdsa-sha2-nistp256-cert-v01@openssh.com),ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521  
debug1: SSH2\_MSG\_KEXINIT sent  
debug1: SSH2\_MSG\_KEXINIT received  
debug2: kex\_parse\_kexinit: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1  
debug2: kex\_parse\_kexinit: [ecdsa-sha2-nistp256-cert-v01@openssh.com](mailto:ecdsa-sha2-nistp256-cert-v01@openssh.com),ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-dss-cert-v00@openssh.com,ssh-rsa,ssh-dss  
debug2: kex\_parse\_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se  
debug2: kex\_parse\_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se  
debug2: kex\_parse\_kexinit: [hmac-md5,hmac-sha1,umac-64@openssh.com](mailto:hmac-md5,hmac-sha1,umac-64@openssh.com),hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96  
debug2: kex\_parse\_kexinit: [hmac-md5,hmac-sha1,umac-64@openssh.com](mailto:hmac-md5,hmac-sha1,umac-64@openssh.com),hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96  
debug2: kex\_parse\_kexinit: [zlib@openssh.com](mailto:zlib@openssh.com),zlib,none  
debug2: kex\_parse\_kexinit: [zlib@openssh.com](mailto:zlib@openssh.com),zlib,none  
debug2: kex\_parse\_kexinit:  
debug2: kex\_parse\_kexinit:  
debug2: kex\_parse\_kexinit: first\_kex\_follows 0  
debug2: kex\_parse\_kexinit: reserved 0  
debug2: kex\_parse\_kexinit: [curve25519-sha256@libssh.org](mailto:curve25519-sha256@libssh.org),ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1  
debug2: kex\_parse\_kexinit: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256  
debug2: kex\_parse\_kexinit: [aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com](mailto:aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com),aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se  
debug2: kex\_parse\_kexinit: [aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com](mailto:aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com),aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se  
debug2: kex\_parse\_kexinit: [hmac-md5-etm@openssh.com](mailto:hmac-md5-etm@openssh.com),hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96  
debug2: kex\_parse\_kexinit: [hmac-md5-etm@openssh.com](mailto:hmac-md5-etm@openssh.com),hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96  
debug2: kex\_parse\_kexinit: [none,zlib@openssh.com](mailto:none,zlib@openssh.com)  
debug2: kex\_parse\_kexinit: [none,zlib@openssh.com](mailto:none,zlib@openssh.com)  
debug2: kex\_parse\_kexinit:  
debug2: kex\_parse\_kexinit:  
debug2: kex\_parse\_kexinit: first\_kex\_follows 0  
debug2: kex\_parse\_kexinit: reserved 0  
debug2: mac\_setup: found hmac-md5  
debug1: kex: server-\>client aes128-ctr hmac-md5 [zlib@openssh.com](mailto:zlib@openssh.com)  
debug2: mac\_setup: found hmac-md5  
debug1: kex: client-\>server aes128-ctr hmac-md5 [zlib@openssh.com](mailto:zlib@openssh.com)  
debug1: sending SSH2\_MSG\_KEX\_ECDH\_INIT  
debug1: expecting SSH2\_MSG\_KEX\_ECDH\_REPLY  
debug1: Server host key: ECDSA ca:9c:7a:11:09:18:01:07:e3:20:68:21:0a:03:8b:71  
debug3: load\_hostkeys: loading entries for host “localhost” from file “/home/klemoine/.ssh/known\_hosts”  
debug3: load\_hostkeys: found key type ECDSA in file /home/klemoine/.ssh/known\_hosts:60  
debug3: load\_hostkeys: loaded 1 keys  
debug1: Host ‘localhost’ is known and matches the ECDSA host key.  
debug1: Found key in /home/klemoine/.ssh/known\_hosts:60  
debug1: ssh\_ecdsa\_verify: signature correct  
debug2: kex\_derive\_keys  
debug2: set\_newkeys: mode 1  
debug1: SSH2\_MSG\_NEWKEYS sent  
debug1: expecting SSH2\_MSG\_NEWKEYS  
debug2: set\_newkeys: mode 0  
debug1: SSH2\_MSG\_NEWKEYS received  
debug1: Roaming not allowed by server  
debug1: SSH2\_MSG\_SERVICE\_REQUEST sent  
debug2: service\_accept: ssh-userauth  
debug1: SSH2\_MSG\_SERVICE\_ACCEPT received  
**debug2: key: /home/klemoine/.ssh/id\_rsa ((nil)) \<\< I wonder why it says nil**  
debug2: key: /home/klemoine/.ssh/id\_dsa ((nil))  
debug2: key: /home/klemoine/.ssh/id\_ecdsa ((nil))  
debug1: Authentications that can continue: publickey,password  
debug3: start over, passed a different list publickey,password  
debug3: preferred gssapi-with-mic,gssapi-keyex,hostbased,publickey  
debug3: authmethod\_lookup publickey  
debug3: remaining preferred: ,gssapi-keyex,hostbased,publickey  
debug3: authmethod\_is\_enabled publickey  
debug1: Next authentication method: publickey  
**debug1: Trying private key: /home/klemoine/.ssh/id\_rsa \<\< This should work, correct key here, proof is that it does work when I run it manually**  
debug1: read PEM private key done: type RSA  
**debug3: sign\_and\_send\_pubkey: RSA a6:13:11:6f:4e:2c:03:a0:87:5a:52:65:50:97:f8:f2 \<\< confirmed this key in github, again, works manually**  
debug2: we sent a publickey packet, wait for reply  
debug1: Authentications that can continue: **publickey** ,password **\<\< seems good here**  
debug1: Trying private key: /home/klemoine/.ssh/id\_dsa  
debug3: no such identity: /home/klemoine/.ssh/id\_dsa  
debug1: Trying private key: /home/klemoine/.ssh/id\_ecdsa  
debug3: no such identity: /home/klemoine/.ssh/id\_ecdsa  
debug2: we did not send a packet, disable method  
debug1: No more authentication methods to try.  
Permission denied (publickey,password). **\<\< whaa ?**

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 2, 2014, 10:23pm UTC](https://forum.ansible.com/t/manual-git-clone-locally-works-but-same-command-using-ansible-localhost-fails/15593/2 "2014-07-02T22:23:25Z")

</div>

This seems like this error is in your generic communication path via Ansible and would also appear with:

ansible local -m ping

And in this case would have nothing to do with git.

Please let us know, but I suspect you may not be using ssh-agent, may need to specify --ask-pass if you wish to use a password, or are using variables like ansible\_ssh\_pass (maybe) and the values are incorrect.

In any case, I don’t think it has anything to do with git.

(BTW, if you want local mode for sure, use -c local)

Thanks!

---

<div class="post-metadata">

**Author:** ![Ken\_Lemoine](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@Ken\_Lemoine](https://forum.ansible.com/u/Ken_Lemoine)\
**Post date:** [July 3, 2014, 9:13pm UTC](https://forum.ansible.com/t/manual-git-clone-locally-works-but-same-command-using-ansible-localhost-fails/15593/3 "2014-07-03T21:13:08Z")

</div>

Michael,

First of all, it was nice meeting you at Ansiblefest NY! So nice to put a person an online persona. 😃

As usual, you fixed me right up with your post. Since I’m using a passphraseless key, it wasn’t any of your first suggestions, but that  
-c local  
does the trick! Not sure why I need that though, never needed it before _shrug_

Added a  
connection: local  
to my playbook, sall good! Many thanks! Ansible rocks!

/kl
