Ansible git clone 'Permission Denied' but direct git clone working -
i got troubling issue ansible. setup git cloning on environment using ssh key of current host:
- name: add user public key copy: src: "/users/alexgrs/.ssh/id_rsa.pub" dest: "/home/vagrant/.ssh/id_rsa.pub" mode: 0644 - name: add user private key copy: src: "/users/alexgrs/.ssh/id_rsa" dest: "/home/vagrant/.ssh/id_rsa" mode: 0600 - name: clone repository git: repo: repo.git dest: /home/vagrant/workspace/ update: true accept_hostkey: true key_file: "/home/vagrant/.ssh/id_rsa.pub"
if vagrant ssh
on vagrant , execute git pull repo
it works. when vagrant provision
got following error message:
stderr: permission denied (publickey). fatal: not read remote repository. please make sure have correct access rights , repository exists.
i'm pretty sure publickey not used vangrant provision i'm not able detect why.
did see kind of issue ?
thank you.
edit: seems ansible not doing git clone trying following command:
/usr/bin/git ls-remote ssh://repo.git -h refs/heads/head
i tried in vagrant box , have same permission denied issue.
copying private keys imho never idea. better option enable ssh agent forwarding.
you can globally in local .ssh/config
:
forwardagent yes
or in ansible.cfg
:
[ssh_connection] ssh_args= -a
in case though need make sure host/vm accepts agent forwarding. in remote /etc/ssh/sshd_config
has defined:
allowagentforwarding yes
Comments
Post a Comment