【发布时间】:2017-12-13 02:12:22
【问题描述】:
我以前发布过这个问题,但那里的答案不再有效。
总之,当我使用 Ansible 配置我的 vagrant box 时,我在尝试使用 ssh 克隆我的 bitbucket 私有 repo 时遇到了一个神秘的错误。错误状态为“权限被拒绝(公钥)”。
然而,如果我 vagrant ssh 然后运行 'git clone' 命令,则私有 repo 被成功克隆。这表明 ssh 转发代理确实在工作,并且 vagrant box 可以访问我与 bitbucket repo 关联的私钥。
我已经在这个问题上苦苦挣扎了两天,我失去了理智!请有人帮帮我!!!
流浪文件:
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: git@bitbucket.org:[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-add -l 确实包含相关的 bitbucket 存储库密钥。
- ssh-add -l vagrant box 内也包含相关的 bitbucket repo 密钥(通过 ssh-forwarding)。
如果在 vagrant box 中手动完成,克隆仍然有效?:
vagrant ssh
git clone git@bitbucket.org: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)
非常感谢任何帮助,感谢您阅读我的噩梦。
【问题讨论】:
-
我没有看到“主机密钥验证”失败,但确实看到了
Permission denied (publickey)错误。也许不要发布重复的问题,而是尝试与人们就您的原始问题进行交流。 -
这不是重复问题,而是一个新问题,因为之前的问题已通过在 playbook.yml 中包含“become: false”行来解决。这是我创建的另一个线程中不存在的新错误消息。请删除重复状态。谢谢。
标签: git ssh vagrant ansible bitbucket