【问题标题】:Ansible 1.6, having problems cloning git rep with ssh agent forwardingAnsible 1.6,在使用 ssh 代理转发克隆 git repo 时遇到问题
【发布时间】:2014-06-17 20:18:40
【问题描述】:

我在使用 ssh 转发从 Git 克隆存储库时遇到问题。这是我的设置:

- name: Setup/pull the Git repo
  git: repo={{ git_repo }} dest={{ git_root }} update=yes accept_hostkey=yes
  when: setup_git_repo
  tags: git deploy
  #git_repo = git@github.com:my_name/repo.git

我从 -vvvv 得到这个调试

<x.x.x.x> ESTABLISH CONNECTION FOR USER: ubuntu
<x.x.x.x> REMOTE_MODULE git repo=git@github.com:name/repo.git dest=/webapps/example-app/example update=yes accept_hostkey=yes
<x.x.x.x> EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ForwardAgent=yes', '-o', u'IdentityFile="/Library/keys/aws-key.pem"', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'User=ubuntu', '-o', 'ConnectTimeout=10', 'x.x.x.x', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1403001910.72-137077614801868 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1403001910.72-137077614801868 && echo $HOME/.ansible/tmp/ansible-tmp-1403001910.72-137077614801868'"]      

我可以看到身份文件不是我想要使用的 id,我的 git 密钥在运行 Ansible 的机器上的 ~/.ssh/ 中。我如何告诉它使用正确的键,或者它为什么不尝试其他键而不是挂起?

我运行 Ansible 时将 'private_key_file' 设置为 aws 密钥。也许这就是问题所在?

我可以通过使用 git 模块的 key_file 变量并将我的 git 私钥上传到我正在配置的服务器来了解这可能是如何实现的。不过我不想这样做,我想从我的 localhost 进行 ssh 转发。

有可能吗?有人可以帮忙吗?

【问题讨论】:

    标签: ansible


    【解决方案1】:

    好的,我终于解决了这个问题。

    首先检查 ssh 代理转发是否在没有 Ansible 的情况下工作。这个列表是一个很好的资源 - https://help.github.com/articles/using-ssh-agent-forwarding

    之后,我只是将它添加到 anisble.cfg 中,一切都按预期工作。

    sudo_flags=-HE
    

    【讨论】:

      猜你喜欢
      • 2018-09-14
      • 1970-01-01
      • 1970-01-01
      • 2013-08-07
      • 2014-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多