# How clone git repository on windows using SSH keys and ssh-agent?

**URL:** <https://forum.ansible.com/t/how-clone-git-repository-on-windows-using-ssh-keys-and-ssh-agent/22496>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [September 6, 2016, 2:38pm UTC](https://forum.ansible.com/t/how-clone-git-repository-on-windows-using-ssh-keys-and-ssh-agent/22496 "2016-09-06T14:38:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![user15](https://avatars.discourse-cdn.com/v4/letter/u/d6d6ee/32.png) [@user15](https://forum.ansible.com/u/user15)\
**Post date:** [September 6, 2016, 2:38pm UTC](https://forum.ansible.com/t/how-clone-git-repository-on-windows-using-ssh-keys-and-ssh-agent/22496/1 "2016-09-06T14:38:16Z")

</div>

Ansible has not git\_win module (see here: [https://groups.google.com/forum/#!searchin/ansible-project/git$20windows|sort:relevance/ansible-project/-uSBtqDPg0s/gPWlTlw3BwAJ](https://groups.google.com/forum/#!searchin/ansible-project/git$20windows%7Csort:relevance/ansible-project/-uSBtqDPg0s/gPWlTlw3BwAJ) )

I use msysgit to clone git repository under windows. Something like:

> - name: clone repositories  
> raw: C:\OpenServer\modules\git\cmd\git.exe clone {{ item.repo }} C:\OPenserver\domains{{ sp.name }}{{ item.path }}
> 
> # version: “{{ item.version | default(‘HEAD’) }}”
> 
> with\_items: “{{ sp.repositories }}”  
> tags:
> 
> - repo

So, there’is an issue: no way to clone repo via SSH protocol.

[This](http://stackoverflow.com/questions/39301265/how-to-clone-git-repository-using-ansible-under-microsoft-windows) works:

> `- name: clone repositories test1`  
> `raw: C:\OpenServer\modules\git\cmd\git.exe clone https://github.com/OpenCorpora/opencorpora.git C:\OPenserver\domains\opencorpora.local\www`  
> ``

```auto

But this fails:

```

> `- name: clone repositories``` test2`` `raw: C:\OpenServer\modules\git\cmd\git.exe clone ```ssh://git@mydomain.tld/myproject.git` C:\OPenserver\domains\testwebsite.local\www`

I’ve got sshd-agent on my server running with appopriate key (works fine on every linux server, no issues to clone repositories on these servers)

Is there an way to clone repos **via SSH forwarding ssh-agent**?

---

<div class="post-metadata">

**Author:** ![Mike\_Fennemore](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Mike\_Fennemore](https://forum.ansible.com/u/Mike_Fennemore)\
**Post date:** [September 6, 2016, 2:44pm UTC](https://forum.ansible.com/t/how-clone-git-repository-on-windows-using-ssh-keys-and-ssh-agent/22496/2 "2016-09-06T14:44:36Z")

</div>

Which version of Windows are you using? Are you using Cygwin or OpenSSH for the sshd-agent?

---

<div class="post-metadata">

**Author:** ![user15](https://avatars.discourse-cdn.com/v4/letter/u/d6d6ee/32.png) [@user15](https://forum.ansible.com/u/user15)\
**Post date:** [September 6, 2016, 2:49pm UTC](https://forum.ansible.com/t/how-clone-git-repository-on-windows-using-ssh-keys-and-ssh-agent/22496/3 "2016-09-06T14:49:31Z")

</div>

Control host is Centos 7, clients – Windows 10.

I use msysgit, it has some wrappers in /cmd folder (git.exe, gitk.cmd and start-ssh-agent.cmd). Should i change git client on windows hosts?

---

<div class="post-metadata">

**Author:** ![Mike\_Fennemore](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Mike\_Fennemore](https://forum.ansible.com/u/Mike_Fennemore)\
**Post date:** [September 6, 2016, 3:30pm UTC](https://forum.ansible.com/t/how-clone-git-repository-on-windows-using-ssh-keys-and-ssh-agent/22496/4 "2016-09-06T15:30:05Z")

</div>

Personally I would just use the client [https://git-scm.com](https://git-scm.com). At least that will also give you the option to add to Windows Path environmental variable.
