Ansible and Git Permission denied (publickey) at Git Clone

前端 未结 3 1307
挽巷
挽巷 2021-02-20 17:11

I have a playbook where I am trying to clone from a private repo (GIT) to a server.

I have setup ssh forwarding and when I ssh into the server and try to manually clone

3条回答
  •  不思量自难忘°
    2021-02-20 17:51

    By reading the documentation for ssh forwarding in ansible. I was able to figure out the solution.

    The problem was that my ssh keys were not being forwarded because Ansible does not by default forward your keys, even if you have set up the key forwarding on ~/.ssh/conf (I updated my question with the ansible.cfg that I had before fixing the issue).

    The solution is was to add transport = ssh to ansible.cfg under [defaults] plus running ansible-playbook from the location where ansible.cfg is located and make sure thet the following setting exists in the /etc/ssh/sshd_config of the target box:

    AllowAgentForwarding yes
    

    My ansible.cfg now looks like this:

    [defaults]
    transport = ssh
    
    [ssh_connection]
    ssh_args = -o ForwardAgent=yes
    

提交回复
热议问题