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

384 views
Skip to first unread message

Андрей Круглов

unread,
Sep 6, 2016, 10:38:16 AM9/6/16
to Ansible Project
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://g...@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?

Mike Fennemore

unread,
Sep 6, 2016, 10:44:36 AM9/6/16
to Ansible Project
Which version of Windows are you using? Are you using Cygwin or OpenSSH for the sshd-agent?

Андрей Круглов

unread,
Sep 6, 2016, 10:49:31 AM9/6/16
to Ansible Project
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?

вторник, 6 сентября 2016 г., 17:44:36 UTC+3 пользователь Mike Fennemore написал:

Mike Fennemore

unread,
Sep 6, 2016, 11:30:06 AM9/6/16
to Ansible Project
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.
Reply all
Reply to author
Forward
0 new messages