Reputation: 116
I've tried almost everything, but still can't believe I can be so dumb.
I do have:
I do have id_rsa & id_rsa.pub key on my mac
I can ssh to vps without the password from my mac
I can run ansible-playbook from my mac to control vps.
But I can't figure out how to 'git clone' my private repo from vps machine.
I ssh-copy-id from my mac to vps - it's there.
I can work with git from my mac - the same id_rsa key.
How to tell git to authorize/allow clone from vps without copying my private id_rsa from mac onto vps or generating side key just for github?
Did I miss something?
Upvotes: 2
Views: 1463
Reputation: 954
Don't know if it may be related but there you go:
- name: Add host to ssh_config
community.general.ssh_config:
host: github.com
hostname: github.com
user: vagrant
identity_file: "/home/vagrant/.ssh/id_rsa"
Upvotes: 0
Reputation: 68479
You need to set up SSH agent forwarding.
In short:
enable agent forwarding on the VPS machine (SSHD config)
tell Ansible to connect with agent forwarding option enabled
for example in ansible.cfg
, section [ssh_connection]
, add -o ForwardAgent=yes
value ssh_args
.
or in ~/.ssh/config
:
Host <VPS_address>
ForwardAgent yes
ensure SSH agent is running and has the keys configured:
eval `ssh-agent -s`
ssh-add
Upvotes: 1