# git module now has sshopts and keyfile parameters

**URL:** <https://forum.ansible.com/t/git-module-now-has-sshopts-and-keyfile-parameters/14410>\
**Category:** Ansible Project\
**Created:** [January 23, 2014, 9:31pm UTC](https://forum.ansible.com/t/git-module-now-has-sshopts-and-keyfile-parameters/14410 "2014-01-23T21:31:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tannerjc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tannerjc/32/985_2.png) [@tannerjc](https://forum.ansible.com/u/tannerjc)\
**Post date:** [January 23, 2014, 9:31pm UTC](https://forum.ansible.com/t/git-module-now-has-sshopts-and-keyfile-parameters/14410/1 "2014-01-23T21:31:57Z")

</div>

Thanks goes to Chris Blossom who did most of the research for this.

[https://github.com/ansible/ansible/commit/18050d50ecf94df95464a560d66d5e8d820ac52c](https://github.com/ansible/ansible/commit/18050d50ecf94df95464a560d66d5e8d820ac52c)

- sshopts  
Creates a wrapper script and exports the path as GIT\_SSH which  
git then automatically uses to override ssh arguments. An  
example value could be “-o StrictHostKeyChecking=no”

- keyfile  
Uses the same wrapper method as sshopts to pass “-i ”  
to the ssh arguments used by git

Test away!

---

<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:** [January 23, 2014, 9:40pm UTC](https://forum.ansible.com/t/git-module-now-has-sshopts-and-keyfile-parameters/14410/2 "2014-01-23T21:40:55Z")

</div>

A few quick updates…

Per argument conventions, these will be “key\_file” and “ssh\_opts” soon.

(Testing is welcome!)

Basically using this you will no longer need to know about tricks where you have to use the “environment” keyword to set “GIT\_SSH” as an environment variable.

In the past, people have typically had to forward SSH keys, and this means that it’s easier to use a different key, such as a GitHub deploy key, rather than yours, if you didn’t know the above tricks.

The accept\_hostkeys argument is also new in 1.5, which solves the problem of having to manually add a git server’s hostkey to known\_hosts prior to using git.

All of this combined together, the git module should be a _TON_ more friendly in 1.5!

---

<div class="post-metadata">

**Author:** ![adam2](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@adam2](https://forum.ansible.com/u/adam2)\
**Post date:** [January 24, 2014, 1:46am UTC](https://forum.ansible.com/t/git-module-now-has-sshopts-and-keyfile-parameters/14410/3 "2014-01-24T01:46:10Z")

</div>

The accept\_hostkey fails if $HOME/.ssh doesn’t already exist.

---

<div class="post-metadata">

**Author:** ![tannerjc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tannerjc/32/985_2.png) [@tannerjc](https://forum.ansible.com/u/tannerjc)\
**Post date:** [January 24, 2014, 3:37am UTC](https://forum.ansible.com/t/git-module-now-has-sshopts-and-keyfile-parameters/14410/4 "2014-01-24T03:37:29Z")

</div>

Please file a bug on github or submit a pull request.

---

<div class="post-metadata">

**Author:** ![adam2](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@adam2](https://forum.ansible.com/u/adam2)\
**Post date:** [January 24, 2014, 5:04pm UTC](https://forum.ansible.com/t/git-module-now-has-sshopts-and-keyfile-parameters/14410/5 "2014-01-24T17:04:16Z")

</div>

I'm new to ansible development, but not test cases, or git. I've  
already been installing ansible by updating my git clone, and building a fresh deb.

Would such a pull request want a test case? I haven't look at all at  
how ansible would want that.

The basic scenario is that my remote\_user is root, I'm connecting to a  
freshly cloned opennebula centos machine, that has nothing on it, except that it allows remote root login. There is no .ssh folder, and I use no key. Later on, when I run git to check out a repo, it tries to create /root/.ssh/authorized\_keys, but the folder doesn't exist.

I have my own rules that create .ssh and .ssh/authoried\_keys, as  
separate tasks, so I'm not held up; I was just trying to use the new  
feature.

---

<div class="post-metadata">

**Author:** ![tannerjc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tannerjc/32/985_2.png) [@tannerjc](https://forum.ansible.com/u/tannerjc)\
**Post date:** [January 24, 2014, 5:11pm UTC](https://forum.ansible.com/t/git-module-now-has-sshopts-and-keyfile-parameters/14410/6 "2014-01-24T17:11:13Z")

</div>

Tests would be really nice, but I’m not sure if we have a good pattern within the existing unit tests to accommodate this situation.

If you can write something up, I would certainly review it and try it out.

BTW, a bug was created this morning for the issue: [https://github.com/ansible/ansible/issues/5750](https://github.com/ansible/ansible/issues/5750)

---

<div class="post-metadata">

**Author:** ![adam2](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@adam2](https://forum.ansible.com/u/adam2)\
**Post date:** [January 24, 2014, 5:23pm UTC](https://forum.ansible.com/t/git-module-now-has-sshopts-and-keyfile-parameters/14410/7 "2014-01-24T17:23:12Z")

</div>

As for tests, I have a complete test system for the internal backup tool I've written and used at $work. I basically start up a user-mode-linux instance, then mount hostfs and overlayfs, so that I can run things as root, it has no outbound network, I then start up a dummy sshd, create a dummy non-root user, then rsync/ssh to test parts of the backup tool.

I had this fake-linux wrapper semi-isolated, but never actually released it. I wonder if it would help for ansible.
