Ansible Playbook:权限被拒绝(公钥),无法从远程存储库读取

时间:2018-07-10 17:41:14

标签: git ssh ansible

我正在运行一个Ansible剧本,以从github提取存储库。我已经生成了ssh密钥并将密钥添加到我的github配置文件中。

我的扮演是:

nvprof --print-api-trace ...

导致以下错误:

- name: Clone git repository
  git: >
    dest=/var/www/PlantMan/
    repo=git@github.com:RockyMountainCollege/PlantMan.git
    update=no

尝试调试ssh进入Web节点并运行

fatal: [web1]: FAILED! => {"changed": false, "cmd": "/usr/bin/git clone --origin origin '' /var/www/PlantMan", "msg": "Cloning into '/var/www/PlantMan'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.", "rc": 128, "stderr": "Cloning into '/var/www/PlantMan'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.", "stderr_lines": ["Cloning into '/var/www/PlantMan'...", "Permission denied (publickey).", 
"fatal: Could not read from remote repository.", "", 
"Please make sure you have the correct access rights", "and the repository exists."], "stdout": "", "stdout_lines": []}

结果:

ssh -vT git@github.com

似乎Web节点可以ssh到github,但是当我运行播放时,它会拒绝访问。

1 个答案:

答案 0 :(得分:1)

如果您的回购是私人的并且首选方法是key_file,请设置ssh

- name: Clone git repository
  git: >
    dest=/var/www/PlantMan/
    repo=ssh://git@github.com/RockyMountainCollege/PlantMan.git
    key_file=/home/vagrant/.ssh/id_rsa
    update=no