我之前发布过这个问题,但那里的答案不再有效。
总之,当使用 Ansible 配置我的 vagrant box 时,在尝试使用 ssh 克隆我的 bitbucket 私有存储库时,我遇到了一个神秘的错误。该错误指出“权限被拒绝(公钥)”。
然而,如果我 vagrant ssh 然后运行“git clone”命令,私有存储库就会成功克隆。这表明 ssh 转发代理确实正在工作,并且 vagrant box 可以访问与 bitbucket 存储库关联的我的私钥。
我在这个问题上纠结了两天了,快疯了!请有人帮助我!
流浪文件:
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.network "private_network", ip: "192.168.33.14"
config.ssh.forward_agent = true
config.vm.provider "virtualbox" do |vb|
vb.memory = "1824"
end
# Only contains ansible dependencies
config.vm.provision "shell",
inline: "sudo apt-get install python-minimal -y"
end
我的playbook.yml如下:
---
- hosts: all
become: true
tasks:
- name: create /var/www/ directory
file: dest=/var/www/ state=directory owner=ubuntu group=www-data mode=0755
- name: Add the user 'ubuntu' to group 'www-data'
user:
name: ubuntu
shell: /bin/bash
groups: www-data
append: yes
- name: Clone [My-Repo] bitbucket repo
become: false
git:
repo: [email protected] /cdn-cgi/l/email-protection:[Username]/[My-Repo].com.git
dest: /var/www/poo
version: master
accept_hostkey: yes
错误信息:ansible-playbook playbook.yml
fatal: [192.168.33.14]: FAILED! => {"changed": false, "cmd": "/usr/bin/git clone --origin origin '' /var/www/poo", "failed": true, "msg": "Cloning into '/var/www/poo'...\nPermission denied (publickey).\r\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.", "rc": 128, "stderr": "Cloning into '/var/www/poo'...\nPermission denied (publickey).\r\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n", "stderr_lines": ["Cloning into '/var/www/poo'...", "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-添加-l在我的机器上确实包含关联的 bitbucket 存储库密钥。
-
ssh-添加-lvagrant 框中还包含关联的 bitbucket 存储库密钥(通过 ssh 转发)。
然而克隆是有效的如果在 vagrant box 内手动完成?:
vagrant ssh
git clone [email protected] /cdn-cgi/l/email-protection:myusername/myprivaterepo.com.git
Then type "yes" to allow the RSA fingerprint to be added to ~/.ssh/known_hosts (as its first connection with bitbucket)
非常感谢任何帮助,并感谢您阅读我的噩梦。