1
votes

I've tried almost everything, but still can't believe I can be so dumb.

I do have:

  • git with private repo
  • vps - trying to control with ansible
  • control machine - mac os

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?

1

1 Answers

1
votes

You need to set up SSH agent forwarding.

In short:

  1. enable agent forwarding on the VPS machine (SSHD config)

  2. 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
    
  3. ensure SSH agent is running and has the keys configured:

    eval `ssh-agent -s`
    ssh-add