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

Ansible has not git_win module (see here: https://groups.google.com/forum/#!searchin/ansible-project/git$20windows|sort: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 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
``


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?

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

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?

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