Home > Software engineering >  How to provide various users access to private git repo without providing a specific username
How to provide various users access to private git repo without providing a specific username

Time:07-05

I am setting up a private terraform repo and was planning to use the following format for accessing the repo via SSH:

"[email protected]:USERNAME/my_private_repo.git"

However, I was wondering if there is a way that I can set this up such that I do not need to add a specific USERNAME each time one of the various user's wants to access a module. So something like this:

"[email protected]/my_private_repo.git"

or

"https://github.com/my_organization/my_private_repo.git"

In the second case I would need a solution that doesn't lead to prompting for the password as it needs to authenticate automatically.

I was reading here that this can be done using https, an oauth token, and dynamic git configuration. Essentially he says he generates a token and then substitutes it into the URL by adding the following into the .gitconfig:

[url "https://oauth2:[email protected]"]
    insteadOf = https://github.com

Would this work for multiple users? Would they each need to know the token and store it somewhere, or is there a better/more secure way of dealing with the token across many users?

CodePudding user response:

Would this work for multiple users

No, a token is generally tied to a user (except deploy token tied to a repository)

SSH would be preferable:

[url "[email protected]:"]
    insteadOf = https://github.com/

That implies each user has register its public SSH key to their GitHub profile.

  • Related