简体   繁体   中英

How do you give a Newly Provisioned Server access to a Private Git Repo with Ansible?

I have provisioned a server with ansibl e and now I would like to clone a private git repo (not github ).

So my local machine's ssh key is authorized on the private git repo and what I have done up till now is copy my local public and private ssh key to the server.

But I feel this is not the best way to go about it.

I know if you are using github you can use the API to create a deploy key. But I am not.

So the only other way I can see is:

  1. Generate ssh key-pair on new server
  2. Copy that newly created ssh key-pair locally with fetch
  3. ssh-copy-id or use authorized_keys to add the servers key to the private git repo

Is there something I am missing, can it be done in another easier way?

You haven't described what your constraints are, and haven't mentioned if you're comfortable creating additional keys and managing them within your private git repo.

Another possible option:

  1. Setup ssh-agent and add your personal key to it before running ansible, and forward your agent to the remote host when you run ansible.

For that solution: SSH Agent Forwarding with Ansible for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM