我对Ansible有一个令人不安的问题.我使用当前主机的ssh键在我的环境中设置了一个git克隆:
- 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"
Run Code Online (Sandbox Code Playgroud)
如果我vagrant ssh
在Vagrant并执行git pull repo
它工作.但是当我这样做时,vagrant provision
我收到以下错误消息:
stderr: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
Run Code Online (Sandbox Code Playgroud)
我很确定我的公钥不被vangrant规定使用,但我无法检测到原因.
你有没有看到这种问题?
谢谢.
编辑: 似乎ansible没有做一个git克隆,但正在尝试以下命令:
/usr/bin/git ls-remote ssh://repo.git -h refs/heads/HEAD
我在我的流浪盒中尝试过,我有同样的权限被拒绝的问题.
udo*_*dan 13
复制私钥恕我直言永远不是一个好主意.更好的选择是启用ssh代理转发.
您可以在本地全局执行此操作.ssh/config
:
ForwardAgent yes
Run Code Online (Sandbox Code Playgroud)
或者在你的ansible.cfg
:
[ssh_connection]
ssh_args= -A
Run Code Online (Sandbox Code Playgroud)
在任何情况下,您都需要确保host/vm接受代理转发.在遥控器/etc/ssh/sshd_config
中,必须定义:
AllowAgentForwarding yes
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6906 次 |
最近记录: |