I am trying to understand the configuration of ssh GitHub with Ansible (I am working on Ansible: Up and Running book). I ran into two problems.
Access denied (publication) - When I first started the playbook ansible-playbook mezzanine.yml, I received permission:
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
Well, right, I see that a few people had this problem. So I jumped into application A when starting Git with SSH and said to start ssh-agent and add id_rsa public key:
eval `ssh-agent -s`
ssh-add ~/.ssh/id_rsa
Conclusion: Identity AddedI ran ssh-agent -lto check and get a long string: 2048 e3:fb:...But I got the same result. So I checked the Github docs on ssh key generation and troubleshooting, which recommended updating the ssh configuration file on my host machine:
Host github.com
User git
Port 22
Hostname github.com
IdentityFile ~/.ssh/id_rsa
TCPKeepAlive yes
IdentitiesOnly yes
. , rsa, .
. , Github " (publicickey)".
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 "me@example.com"
.ssh git_rsa.pub. :
$ ssh -i ~/.ssh/git_rsa.pub -T git@github.com
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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). Github, , ssh-rsa. . ( -BEGIN PRIVATE KEY--, ); , , .
Ansible YAML:
- name: check out the repository on the host
git: repo={{ repo_url }} dest={{ proj_path }} accept_hostkey=yes
vars:
repo_url: git@github.com:lorin/mezzanine-example.git
ansible.cfg ForwardAgent:
[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
Ubuntu Trusty64 Mac OS. - / Github, .