我试图理解与Ansible的GitHub sshconfiguration(我正在Ansible:Up&Running书上工作)。 我遇到两个问题。
权限被拒绝(publickey) – 当我第一次运行ansible-playbook mezzanine.yml剧本时,我被拒绝了一个权限:
failed: [web] => {"cmd": "/usr/bin/git ls-remote '' -h refs/heads/HEAD", "failed": true, "rc": 128} stderr: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. msg: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. FATAL: all hosts have already failed -- aborting
好吧,我看到有几个人有这个问题。 所以我跳到附录A上,用SSH运行Git,它说运行ssh-agent并添加id_rsa公钥:
eval `ssh-agent -s` ssh-add ~/.ssh/id_rsa
输出: Identity Added我运行ssh-agent -l来检查并得到长string: 2048 e3:fb:...但是我得到了相同的输出。 所以我检查了关于ssh密钥世代的Github文档,并且build议更新我的主机上的sshconfiguration文件:
Host github.com User git Port 22 Hostname github.com IdentityFile ~/.ssh/id_rsa TCPKeepAlive yes IdentitiesOnly yes
但是这仍然提供相同的错误。 所以在这一点上,我开始认为这是我的rsa文件,这导致我的第二个问题。
密钥生成问题 – 我试图生成一个额外的证书使用,因为Githubtesting抛出了另一个“权限被拒绝(公钥)”的错误。
Warning: Permanently added the RSA host key for IP address '192.30.252.131' to the list of known hosts. Permission denied (publickey).
我从头开始遵循Github指令,并使用不同的名称生成一个新的密钥。
ssh-keygen -t rsa -b 4096 -C "[email protected]"
我没有input密码并将其保存到名称为git_rsa.pub的.ssh文件夹中。 我跑了相同的testing,得到以下内容:
$ ssh -i ~/.ssh/git_rsa.pub -T [email protected] @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0644 for '/Users/antonioalaniz1/.ssh/git_rsa.pub' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored. bad permissions: ignore key: ~/.ssh/github_rsa.pub Permission denied (publickey).
我检查了权限,并在文件上做了一个chmod 700 ,我仍然获得Permission denied (publickey) 。 我甚至试图将密钥input到我的Github帐户,但是首先得到一个消息,即密钥文件需要以ssh-rsa开头。 所以我开始研究和黑客。 在文件中input长string(以–BEGIN PRIVATE KEY–开头,但在失败后我省略了这部分)开始。 然而,Github不接受,说这是无效的。
这是我在YAML文件中的Ansible命令:
- name: check out the repository on the host git: repo={{ repo_url }} dest={{ proj_path }} accept_hostkey=yes vars: repo_url: [email protected]:lorin/mezzanine-example.git
这是configuration了ForwardAgent的ansible.cfg文件:
[defaults] hostfile = hosts remote_user = vagrant private_key_file = .vagrant/machines/default/virtualbox/private_key host_key_checking = False [ssh_connection] ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o ForwardAgent=yes
该框是一个使用Mac OS的Ubuntu Trusty64。 如果任何人都可以告诉我的文件权限和/或Github密钥生成,我将不胜感激。
我在我的ansible.cfg有transport = paramiko来修复一个不同的bug,但是似乎是导致ForwardAgent=yes问题。 刚卸下运输,它再次工作。
~/.ssh/ dir, ~/.ssh/config文件。 如果您的公钥使用默认名称(“ ìd_rsa.pub , id_ed25519.pub , id_dsa.pub ),则id_ed25519.pub /etc/ansible/ansible.cfgconfiguration文件。 ~/.ssh/id_rsa私人文件(我有我的0x600 )。 offtopic:“盒子是使用Mac OS的Ubuntu Trusty64”?!?!